[FLOW3-general] DateTime and FLUID-Form

Mathis Hoffmann mathis at hoffpost.de
Sat Aug 27 17:54:58 CEST 2011


Great!!! That works!!! Thank you so much :)



2011/8/27 Ferdinand Kuhl <fcool at coolys.de>:
> Yeah, we are nailing it down:
>
> Try it like this:
>
>        /**
>         * Initialize the create action
>         *
>         * @return void
>         */
>        public function initializeCreateAction() {
>                $this->arguments['newEvent']->
>                     getPropertyMappingConfiguration()
>                     ->forProperty('NAMEOFYOURDATETIMEPROPERTY') // this
> line can be skipped in order to specify the format for all properties
>                     -
>>setTypeConverterOption('TYPO3\FLOW3\Property\TypeConverter\DateTimeConverter',
>                     \TYPO3\FLOW3\Property\TypeConverter\DateTimeConverter::CONFIGURATION_DATE_FORMAT,
> 'd.m.Y'');
>        }
>
> Mathis Hoffmann wrote:
>
>> Thanks Ferdinand, but I could not solve the problem. I can't find any
>> documentation about using these initialize*Action-methods. I do
>> unterstand that I could influence the arguments that will be passed to
>> the specific Action-method using this function. I found out that
>> $this->arguments->getArgument('newEvent') returns the object that
>> contains the submitted values and will later be passed to the
>> action-method. But configuring the propertyMapper for that argument
>> fails.
>>
>> I tried the following:
>>
>> /**
>> * Initialize the create action
>> *
>> * @return void
>> */
>> public function initializeCreateAction() {
>> $newEvent = $this->arguments->getArgument('newEvent');
>> $conf = $this->propertyMappingConfigurationBuilder->build();
>> $conf->forProperty('date');
>> $conf-
>>setTypeConverterOption('TYPO3\FLOW3\Property\TypeConverter\DateTimeConverter',
>>
> \TYPO3\FLOW3\Property\TypeConverter\DateTimeConverter::CONFIGURATION_DATE_FORMAT,
>> 'd.m.Y');
>> $newEvent = $this->propertyMapper->convert($newEvent,
>> 'Plan\Domain\Model\Event', $conf);
>> $this->arguments->addArgument($newEvent);
>> }
>>
>> That ends up in:    #1297759968: Exception while property mapping at
>> property path "":The source is not of type string, array, float,
>> integer or boolean, but of type "object".
>>
>> Does anyone have an idea?
>>
>>
>>
>> 2011/8/27 Ferdinand Kuhl <fcool at coolys.de>:
>>> Hey Matthias,
>>>
>>> I'm not quite sure, if this will help you, but I am pretty convinced that
>>> the configuration of the property matter in createAction is "too late".
>>> So my suggestion would be to revert the "ArrayCollection" to its origin
>>> and move propertyConfiguration to a initialize-method
>>> (initializeCreateAction)
>>>
>>> and do there stuff like this:
>>> $this->arguments['machineModel']->getPropertyMappingConfiguration()-
>>>>setTypeConverterOption('...');
>>>
>>> Hope this takes you a step forward.
>>>
>>> Greetings from sunny germany,
>>> Ferdinand
>>>
>>> Mathis Hoffmann wrote:
>>>
>>>> Hello,
>>>>
>>>> I have problems using a FLUID-Form with a text-field where the user
>>>> could enter a date (like 13.10.2011) plus two simple string-fields
>>>> (name & title). I have a model \Plan\Domain\Model\Entry with the
>>>> attribute \DateTime $date. The FLUID-Form sends data to a createAction
>>>> in my StandardController, which expects an object of the type
>>>> \Plan\Domain\Model\Entry. When I submit the form FLOW3 tells me about
>>>> problems with the PropertyMapper. Therefore I changed the object-type
>>>> which createAction expects to
>>>> \Doctrine\Common\Collections\ArrayCollection an tried to handle the
>>>> request using the propertyMappingConfigurationBuilder with the
>>>> following configuration:
>>>>
>>>> /**
>>>> * Create action
>>>> *
>>>> * @param \Doctrine\Common\Collections\ArrayCollection $newEvent The new
>>>> event * @return void
>>>> */
>>>> public function createAction($newEvent) {
>>>> $conf = $this->propertyMappingConfigurationBuilder->build();
>>>> $conf->forProperty('date');
>>>> $conf-
>>>>setTypeConverterOption('TYPO3\FLOW3\Property\TypeConverter\DateTimeConverter',
>>>>
>>>
> \TYPO3\FLOW3\Property\TypeConverter\DateTimeConverter::CONFIGURATION_DATE_FORMAT,
>>>> 'd.m.Y');
>>>> $newEvent = $this->propertyMapper->convert($newEvent,
>>>> 'Plan\Domain\Model\Event', $conf);
>>>> $this->eventRepository->add($newEvent);
>>>> $this->redirect('index');
>>>> }
>>>>
>>>> This ends up in #1297759968: Exception while property mapping at
>>>> property path "title":The target type was no string, but of type
>>>> "NULL". So my question is: What is the simpliest way to handle such a
>>>> date-input in combination with other form-fields?
>>>>
>>>> Thanks in advance for any suggestion!
>>>>
>>>> Greetings from Germany
>>>> Mathis Hoffmann
>>>
>>> _______________________________________________
>>> FLOW3-general mailing list
>>> FLOW3-general at lists.typo3.org
>>> http://lists.typo3.org/cgi-bin/mailman/listinfo/flow3-general
>>>
>
> _______________________________________________
> FLOW3-general mailing list
> FLOW3-general at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/flow3-general
>


More information about the FLOW3-general mailing list