Hello to everyone,
In an
modObjectUpdateProcessor I try to save an object A and its one-to-one related object B. The data coming from the request shows if A is already related to one B or not.
So, if there is no relationship I want to create a new B and add to A. That is why I use:
public function beforeSave() {
if (A not related to any B) {
$newB = $this->modx->newObject('B', array with B's properties);
$this->object->addOne($newB);
}
return parent::beforeSave();
}
However, the above code results in
two new entries in the relationship table, instead of the one I expect.
Can anyone explain why this is happening?
Thanks a lot.