[TYPO3-mvc] Set relation

Dawid Pacholczyk dpacholczyk at gmail.com
Thu Jan 13 17:38:17 CET 2011


On 13.01.2011 16:21, Franz Koch wrote:
> 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.
>

Yes you were right about what is pUid

Btw i found that 10 minutes before you wrote as you can see on mailing 
list. Sometimes I look to hard for such easy thing :)

Thank you for your time

Regards,
Dawid Pacholczyk


More information about the TYPO3-project-typo3v4mvc mailing list