Hi, I’m receiving the following data in a webservice, note the sections element, that contains categories, then items
Yet, after I succesfully store almost all the information using this code:
public function post() {
$this->storeArray('sections', 'Sections');
return $this->success('Succesful call!');
}
public function put(){
$this->post();
}
private function storeArray($propName, $objName) {
$optionsList = $this->properties[$propName];
foreach ($optionsList as $option) {
$newOption = $this->modx->newObject($objName);
$newOption->fromArray($option, '', true);
$newOption->save();
}
}
The stored data ends up without items element:
[
{
"id": 4,
"icon": "flag",
"main": false,
"name": "234324",
"items": [],
"visible": true
},
{
"id": 5,
"icon": "flag",
"main": false,
"name": "asdfasdfas",
"items": [],
"visible": true
}
]
My XML definition for this particular table is:
<object class="Sections" table="booking_sections" extends="xPDOSimpleObject">
<field key="categories" dbtype="json" phptype="json" null="true"/>
<field key="treeData" dbtype="json" phptype="json" null="true"/>
<field key="icon" dbtype="varchar" precision="50" phptype="string" null="false" default=""/>
<field key="name" dbtype="varchar" precision="50" phptype="string" null="false" default=""/>
<field key="main" dbtype="boolean" phptype="boolean" null="false" default=""/>
</object>
What puzzles me the most is that the treeData property is even more complex than the categories, yet all data is stored and retrieved without problem, any idea of what I’m missing?
Edit: I keep debugging and found out that even before inserting the object contains the proper array inside the xpdobject class, I’m I hitting some sort of reserved word?
Just read this before shuting down, I’ll give the raw param a try tomorrow