[Flow] \DateTimeConverter

Bastian Waidelich bastian at typo3.org
Fri Jun 21 12:06:02 CEST 2013


mario chiari wrote:

Hi Mario,

> The following works
>
> public function initializeUpdateAction() {
> 	  $this->arguments['father']
> 	->getPropertyMappingConfiguration()
> 	->forProperty('father_date')
> 	->setTypeConverterOption('TYPO3\Flow\Property\TypeConverter
> \DateTimeConverter', \TYPO3\Flow\Property\TypeConverter
> \DateTimeConverter::CONFIGURATION_DATE_FORMAT, 'd-m-Y');
>
>    $this->arguments['father']
> 	->getPropertyMappingConfiguration()
> 	->forProperty('sons.0.son_date')
> 	->setTypeConverterOption('TYPO3\Flow\Property\TypeConverter
> \DateTimeConverter',\TYPO3\Flow\Property\TypeConverter
> \DateTimeConverter::CONFIGURATION_DATE_FORMAT,'d-m-Y');
>
>    $this->arguments['father']
> 	->getPropertyMappingConfiguration()
> 	->forProperty('sons.1.son_date')
> 	->setTypeConverterOption('TYPO3\Flow\Property\TypeConverter
> \DateTimeConverter',\TYPO3\Flow\Property\TypeConverter
> \DateTimeConverter::CONFIGURATION_DATE_FORMAT,'d-m-Y');
> 	}
>
> Clearly, it is a ugly fix.
> But I am not able to use something like <sons.*.son_date>. Why? Where
> should look for a mistake?

Yes, that should be possible since [1] is resolved (~6 months).

If you know that you always have sons.0 and sons.1 I don't think that 
the hack is too bad, but you could also send the date format 
configuration from the Fluid form by adding a hidden field with the name 
"dateFormat" (have a look at the DatePickerViewHelper provided by the 
Form framework [2]).

[1] http://forge.typo3.org/issues/37436
[2] 
https://git.typo3.org/FLOW3/Packages/TYPO3.Form.git/blob/HEAD:/Classes/TYPO3/Form/ViewHelpers/Form/DatePickerViewHelper.php

-- 
Bastian Waidelich
--
Core Developer Team

TYPO3 .... inspiring people to share!
Get involved: typo3.org


More information about the Flow mailing list