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

Ferdinand Kuhl fcool at coolys.de
Wed Aug 31 10:48:08 CEST 2011


Sorry again. :(

Using public attributes will prohibit doctrine to generate proxy-classes, 
which in generally is a very bad thing.

The only thing I can see is the custom column-type-definition. Perhaps the 
mapping infrastructure is not sure about "date".

Could you remove the "@Column" annotation and try again?

Hint: Using qualified mehtod arguments like this

public function setBirthdate(\DateTime $birthdate) {
$this->birthdate = $birthdate;
}

will help you to detect a bunch of errors more early.

Dawid Pacholczyk wrote:

> Yes I found that.
> As I wrote in my second message.
> 
> I get exception
> #1297759968: Exception while property mapping at property path
> "":Property "birthdate" could not be set in target object of type
> "My\Package\Domain\Model\User"
> 
> When I change this attribute to public it works. Is it good ? Or am I
> missing something ?
> 
> So format of date is correct. I can`t modify field. When I change
> birthdate to public there is no exception. I have setter for this field
> with as a public method.
> 
> W dniu 2011-08-31 10:15, Ferdinand Kuhl pisze:
>> *argh*
>> Sorry Dawid. I think I found your problem:
>>
>> Compare your date with your given format. In your initialize you define
>> the date:
>>
>> 
\TYPO3\FLOW3\Property\TypeConverter\DateTimeConverter::CONFIGURATION_DATE_FORMAT,
>> 'd.m.Y'
>>
>> And in the form you enter:
>>
>> 10-05-2011
>>
>> (which would be "d-m-Y")
>>
>> So adjust your Format-String in the TypeConverter or try:
>> 10.05.2011
>>
>> Greetz,
>> Ferdinand
>>
>> Dawid Pacholczyk wrote:
>>
>>> 1) No, I did not forget about setter. I have both, setter and getter for
>>> this field. Setter is set as public
>>>
>>> 2) I`ve found 2 days ago. I used the same example. I`ve changed only
>>> fields name.
>>>
>>> That`s why I`m looking for help
>>>
>>> Best regards,
>>> Dawid Pacholczyk
>>>
>>> W dniu 2011-08-31 01:59, Ferdinand Kuhl pisze:
>>>> Hi Dawid,
>>>>
>>>> for your problem with Datetime search the newsgroup. Mathis had the
>>>> same problem.
>>>>
>>>> Search for "DateTime and FLUID-Form".
>>>>
>>>> Greetings,
>>>> Ferdinand
>>>>
>>>> Dawid Pacholczyk wrote:
>>>>
>>>>> Hello List,
>>>>>     I have problem with mapping or maybe with adding nested models and
>>>>> DateTime
>>>>>
>>>>> 1. I have user model that is associated with address model. Address
>>>>> has 3 fields that are not properties of user. How can I create *one*
>>>>> form where I can add properties of user and address with out exception
>>>>> ? How should I fetch data ?
>>>>>
>>>>> 2. I can convert string to DateTime object. I have
>>>>>
>>>>> /**
>>>>> * Users birthdate
>>>>> *
>>>>> * @var \DateTime
>>>>> * @Column(type="date")
>>>>> */
>>>>> protected $birthdate;
>>>>>
>>>>> <f:form.textbox property="birthdate" id="birthdate" />
>>>>>
>>>>> /**
>>>>> * Initialize createAction
>>>>> *
>>>>> * @return void
>>>>> */
>>>>> public function initializeCreateAction() {
>>>>>
>>>>> $this->arguments['newUser']->getPropertyMappingConfiguration()-
>>>>> forProperty('birthdate')-
>>>>>
>> 
setTypeConverterOption('TYPO3\FLOW3\Property\TypeConverter\DateTimeConverter',
>>>>>
>>>>>
>>>>
>> 
\TYPO3\FLOW3\Property\TypeConverter\DateTimeConverter::CONFIGURATION_DATE_FORMAT,
>>>>> 'd.m.Y');
>>>>> }
>>>>>
>>>>>
>>>>> But I keep getting exception
>>>>>
>>>>> #1297759968: Exception while property mapping at property path
>>>>> "birthdate":The string"10-05-2011" could not be converted to DateTime
>>>>> with format "d.m.Y"
>>>>>
>>>>> What am I doing wrong ?
>>>>>
>>>>> Best regards,
>>>>> Dawid Pacholczyk
>>>>
>>



More information about the FLOW3-general mailing list