I am using the Ext Direct php files.

Read, Update, and Delete work great on the server side. However, I am having a problem with the Create call. The EventId parameter is always empty when the router.php calls the createRecord function in my implementation class.

All other parameters are correct and the other functions work great. I am at a loss to figure this out.

Below are the model and event definitions:

Ext.define("MyApp.model.Event", {
extend : 'Sch.model.Event',
fields : [
{name: 'Id'},
{name: 'ResourceId'},
{name: 'EventId'},
{name: 'StartDate', type: 'date',dateFormat: 'Y-m-d G:i'},
{name: 'EndDate', type: 'date',dateFormat: 'Y-m-d G:i'}
]
})

// Store holding all the tasks
var eventStore = Ext.create("Ext.data.JsonStore", {
model : 'MyApp.model.Event',
autoSync:true,
proxy: {
type: 'direct',
api: {
create: PAssignments.createRecord,
read: PAssignments.getResults,
update: PAssignments.updateRecords,
destroy: PAssignments.destroyRecord
}
}
});

Here is the code that adds the new record to the store. fieldEventId is logged to the console as being 11. (Hardcoding the value does not help either).

view.eventStore.add(new Sch.model.Event({

EventId : fieldEventId,
ResourceId : fieldResourceId,
StartDate : fieldStartDate,
EndDate : fieldEndDate,

}));


Below is the PHP CreateRecord call. The router calls this function. The file logging shows that all params except EventId are good.

public function createRecord($params)
{
$myFile = "directAPILog.txt";
$fh = fopen($myFile, 'w') or die("can't open file");

fwrite($fh, "PAssignments::createRecord ");

$_db = $this->__construct();

fwrite($fh, "params->ResourceId = " . $params->ResourceId . "\n");
fwrite($fh, "params->EventId = " . $params->EventId . "\n");
fwrite($fh, "params->StartDate = " . $params->StartDate . "\n");
fwrite($fh, "params->EndDate = " . $params->EndDate . "\n");
fwrite($fh, "----------------------------\n");

if($stmt = $_db->prepare("INSERT INTO RS_People_Event_Assignments (ResourceId, EventId, StartDate, EndDate) VALUES (?, ?, ?, ?)")) {

$stmt->bind_param('iiss', $ResourceId, $EventId, $StartDate, $EndDate);


$ResourceId = $_db->real_escape_string($params->ResourceId);
$EventId = $_db->real_escape_string($params->EventId);
$StartDate = $_db->real_escape_string($params->StartDate);
$EndDate = $_db->real_escape_string($params->EndDate);

$stmt->execute();

$params->Id = $_db->insert_id;

fwrite($fh, "params->Id = " . $params->Id . "\n");

$stmt->close();
}

fclose($fh);

return $params;
}