I have a couple of related objects in a database that I need to update from the same form. It's a simple address object related to a contact object VIA 1:1 relation.
I can swear that when I was retrieving the object at one point I was setting all the placeholders in one $object->toArray() call, but that seems to not be the case anymore. [I am not sure what changed]
Here is what I am doing now, which does work:
$thisEntity = $this->modx->getObject('Entities', array('id' => $entity, 'token' => $token));
$entityData = $thisEntity->toArray();
// extra lines
$entityContacts = $thisEntity->EntityContact->toArray();
foreach($entityContacts as $key => $value){
$entityData[$key] = $value;
}
// extra lines
$this->modx->setPlaceholders($entityData, 'fi.');
I'm sure at one point I wasn't using the extra lines and had the form populated, but not how.
Is there a faster easier way to populate the placeholder array [$entityData] from the Entities object and the EntityContact object in one step?