[FLOW3-general] Mapping and adding objects - problem with properties

Dawid Pacholczyk dpacholczyk at gmail.com
Wed Aug 31 22:06:57 CEST 2011


THe relation is @OneToMany

One user many Addresses

I have and ArrayCollection. I`ve managed to remap data from form as an 
object. Now I need to add it to collection

#1: Catchable Fatal Error: Argument 1 passed to 
Doctrine\Common\Collections\ArrayCollection::__construct() must be an 
array, object given, called in 
D:\wamp\www\directory\Packages\Framework\Doctrine\Classes\ORM\UnitOfWork.php 
on line 416 and defined in 
D:\wamp\www\directory\Packages\Framework\Doctrine\Classes\Common\Collections\ArrayCollection.php 
line 46

but I`m getting further and further thanks to you :)

W dniu 2011-08-31 21:50, Ferdinand Kuhl pisze:
> The lines I suggested you do work for me on many use cases.
>
> What kind of relation? OneToOne, OneToMany, ManyToOne or ManyToMany?
>
> Dawid Pacholczyk wrote:
>
>> I went this way
>>
>>
>> $this->arguments['newUser']->getPropertyMappingConfiguration()-
>> forProperty('address')-
>> setTypeConverterOption('TYPO3\FLOW3\Property\TypeConverter\PersistentObjectConverter',
>>
> \TYPO3\FLOW3\Property\TypeConverter\PersistentObjectConverter::CONFIGURATION_CREATION_ALLOWED,
>> true);
>>
>> $this->arguments['newUser']->getPropertyMappingConfiguration()-
>> setTargetTypeForSubProperty('address',
>> 'My\Package\Domain\Model\Address');
>>
>> but I`m getting
>>
>> #1297759968: Exception while property mapping at property path
>> "address":Creation of objects not allowed. To enable this, you need to
>> set the PropertyMappingConfiguration Value
>> "CONFIGURATION_CREATION_ALLOWED" to TRUE
>>
>> W dniu 2011-08-31 19:06, Ferdinand Kuhl pisze:
>>> No Problem! I'm sure we all had similar experiences before. ;)
>>>
>>> What kind of relation?
>>>
>>> Basically you will have to do the following:
>>>
>>> FLUID-Form:
>>>
>>> <f:form.textfield property="address.city" />
>>> <f:form.textfield property="address.zip" />
>>> ...
>>>
>>> And in your Controller:
>>>
>>> public function initializeCreateAction() {
>>>       $this->arguments['newUser']->getPropertyMappingConfiguration()-
>>>> allowCreationForSubProperty('address');
>>> }
>>>
>>> The rest should Flow3 do for you ;)
>>>
>>> Have a nice evening,
>>> Ferdinand
>>>
>>> Dawid Pacholczyk wrote:
>>>
>>>> OH MY GOD !!!!!!!!!!!!!!!!!!!!
>>>>
>>>> Sorry but I lost 2 days for that :/ I`ve changed the field, I`ve changed
>>>> the getter but I had to forget about setter. Thank you Sebastian
>>>>
>>>> Ferdinand big thank you to you too for your time
>>>>
>>>> Guys, what about second question ? I have association with Address
>>>> object and I would like to put in my New.html 3 fields from address
>>>>
>>>> street, city, zip
>>>>
>>>> They are not User properties but Address properties. How can I in
>>>> initial method receive values and combine them to Address object and
>>>> invoke setAddress ?
>>>>
>>>> Best regards,
>>>> Dawid Pacholczyk
>>>>
>>>> W dniu 2011-08-31 18:38, Sebastian Kurfürst pisze:
>>>>> Hey,
>>>>>
>>>>>> public function setAge($birthdate) {
>>>>>>            $this->birthdate = $birthdate;
>>>>>>        }
>>>>>
>>>>> That's the error :-) It must be "public function setBirthdate".
>>>>>
>>>>> Greets,
>>>>> Sebastian
>>>>>
>>>
>



More information about the FLOW3-general mailing list