Ok guys, working ExtJS4 and I have pretty much the exact opposite problem this guy did:
How do I get an ExtJS JsonStore to put the JSON data directly into the request body?
In my application I have a nested data structure being loaded with associated models.
CakePHP in the backend expects (in pseudocode) the following format in saves:
[
{
[Model]
[Field1]: [Value1],
[Field2]: [Value2],
[Field3]: [Value3]
},
{
[Model]
[Field1]: [Value1],
[Field2]: [Value2],
[Field3]: [Value3]
}
]
This is what ExtJS is currently sending to the server:
[
{
[Field1]: [Value1],
[Field2]: [Value2],
[Field3]: [Value3],
[Model] : null
}
]
So, for some reason it's including the model as a null value and putting the parameters in the root node of the Json object.
The server sends the data to the client in a similar fashion but the Json Reader for the Json Proxy has a record parameter (See here). Unfortunately the Json Writer has no such property (not even undocumented as I have tried setting it).
Currently my workaround on the back end is:$json = Set::insert($json, 'Model', $json);
But it would be good if there was a better way to accomplish this.
Update: To further expand, I am loading one store which loads nested Json data that automatically populates associated models in the client. (This is all done with Extjs methods without any custom code).
I have tried the root property in the Json writer but unforunatly with batch records it formats the request like this:
{
[Root] : [
{
[Field1]: [Value1],
[Field2]: [Value2],
[Field3]: [Value3],
[Model] : null
},
{
[Field1]: [Value1],
[Field2]: [Value2],
[Field3]: [Value3],
[Model] : null
}
]
}
I have also tried Bancha (http://banchaproject.org) but I was unable to get that to work with Sencha Architect (which is being used for this project) and the solution they have provided at the moment was a "workaround" (which I was unable to get working).
Thank you, -T6