[TYPO3-mvc] Persist 1:n relation objects

Heiko Kromm | Paints h.kromm at paints.de
Tue Oct 15 16:14:06 CEST 2013


Hi List, 

I have a command controller, which creates new objects which are added as 1:n relation to an existing object. 

Unfortunatly the new objects are not persisted. 
In short, this is what I have: 

$parentObject = $this->parenttestRepository->findByUid(1); 

$childObject = new \VendorName\Extension\Domain\Model\Childtest; 
$childObject->setProp1('Test'); 

$parentObject->addChildtest($childObject); 

$this->parenttestRepository->update($parentObject ); 


If I change another property of the parent object which is not of type \TYPO3\CMS\Extbase\Persistence\ObjectStorage the new created child objects are persisted. 

$parentObject = $this->parenttestRepository->findByUid(1); 

$childObject = new \VendorName\Extension\Domain\Model\Childtest; 
$childObject->setProp1('Test'); 

$parentObject->setTitle('Change me to get childs persisted') ; 

$parentObject->addChildtest($childObject); 

$this->parenttestRepository->update($parentObject ); 

Is this a bug, or do I have to change something in my model? The child object are lazy loaded. Could this cause problems? 

I'm on T3V6.1.5 

Regards 
Heiko 


More information about the TYPO3-project-typo3v4mvc mailing list