[FLOW3-general] DateTime and FLUID-Form

Ferdinand Kuhl fcool at coolys.de
Sat Aug 27 15:19:47 CEST 2011


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



More information about the FLOW3-general mailing list