[FLOW3-general] Own TypeConverter
Manfred Rutschmann - VOLUMEN Werbe-/Internetagentur
rutschmann at agentur-volumen.de
Wed Mar 6 11:24:06 CET 2013
Hi guys,
ich have extended my converter by this:
/**
* Only convert strings with given format
*
* @param mixed $source
* @param string $targetType
* @return boolean
*/
public function canConvertFrom($source, $targetType) {
return preg_match("/^[0-9]+[h] [0-9]+[m][i][n]$/", $source);
}
Ist this the right way? Now the integer properties are not applied by this.
Regards Manfred
Am 06.03.2013 um 10:32 schrieb Manfred Rutschmann - VOLUMEN Werbe-/Internetagentur <rutschmann at agentur-volumen.de>:
> Hi list,
>
> one question about type converter:
>
> In my model i have a field named estimatedtime, stored with seconds in the database. In the frontend the user can make this input:
>
> 1h 30min
>
> I have written a own simple typeconverter like this:
>
> http://pastebin.com/qcAbepTA
>
> I used this converter in my initializeUpdateAction:
>
> /**
> * initializeCreateAction
> * @return void
> */
> public function initializeUpdateAction() {
> $this->arguments["aufgabe"]
> ->getPropertyMappingConfiguration()
> ->forProperty('faellig')
> ->setTypeConverterOption('TYPO3\FLOW3\Property\TypeConverter\DateTimeConverter', \TYPO3\FLOW3\Property\TypeConverter\DateTimeConverter::CONFIGURATION_DATE_FORMAT, 'd.m.Y H:i');
>
> $this->arguments["aufgabe"]
> ->getPropertyMappingConfiguration()
> ->forProperty('estimatedtime')
> ->setTypeConverterOption('Kunden\Property\TypeConverter\HourMinuteToSecondsConverter', 'integer', NULL);
>
> $this->arguments['aufgabe']->getPropertyMappingConfiguration()->allowProperties('company');
> $this->arguments['aufgabe']->getPropertyMappingConfiguration()->allowProperties('projekt');
> }
>
> I have set the converter here only for the property estimatedtime, but flow applies this Converter to ALL defined integers in my model.
> Because of this i get by every property on the form that is defined as integer a error like "No hour or Minute give"
>
> Why? I have no idea...
>
> Thanks & regards Manfred
> _______________________________________________
> 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