[FLOW3-general] Mapping and adding objects - problem with properties
Ferdinand Kuhl
fcool at coolys.de
Wed Aug 31 21:50:00 CEST 2011
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