[TYPO3-mvc] Set relation
Franz Koch
typo3.RemoveForMessage at elements-net.de
Thu Jan 13 16:21:25 CET 2011
Hey,
> I`m wondering on some thing. I have mm relation beetwen object Record
> and object Portal
>
> I have one connection Record1 <-> Portal1
>
> Now I want to add connection beetwen Record1 <-> Portal2
>
> How can I do that ?
>
> First I used setPUid but I received
>
> PHP Catchable Fatal Error: Argument 1 passed to
> Tx_Ext_Domain_Model_Record::setPUid() must be an instance of
> Tx_Extbase_Persistence_ObjectStorage, instance of
> Tx_Ext_Domain_Model_Portal given,
>
> first of all it generates error, secondly It would replace the old
> connection. How to add another value so it would be saved in database ?
Without knowing your models and thus knowing what PUid is, it's a bit
hard to tell. Because you get the error message that a objectStorage is
required, I suppose PUid is your MM relation that can have multiple
related objects, is it? Then your model should also have the methods
"addPUid" and "removePUid" as long as you created it with the
kickstarter - doesn't it? If they are there, use those - if not
something went wrong with your kickstarter and you have to add them
manually.
// proper annotations
public function addPUid(Tx_Ext_Domain_Model_Portal $portal) {
$this->pUids->attach($portal);
}
// proper annotation
public function removePUid(Tx_Ext_Domain_Model_Portal $portal) {
$this->pUids->detach($portal);
}
Btw - the naming of "pUid" is quite cryptic and not reflecting that it
could contain more then one object.
--
kind regards,
Franz Koch
More information about the TYPO3-project-typo3v4mvc
mailing list