[TYPO3-mvc] Setting typeconverter of childobject

Werner Stotter typo3 at itfix.at
Fri Jan 30 06:57:21 CET 2015


Hi Douwe,

just use another ->forProperty to access the child objects properties in 
your initializeUpdateAction():

public function initializeUpdateAction() {
  $this->arguments['order']
    ->getPropertyMappingConfiguration()
    ->forProperty('orderProperty')
    ->setTypeConverter(new 
\Cmp\Ext\Property\TypeConverter\AmountToFloatConverter);

  $this->arguments['order']
    ->getPropertyMappingConfiguration()
    ->forProperty('orderLine')
    ->forProperty('amount')
    ->setTypeConverter(new 
\Cmp\Ext\Property\TypeConverter\AmountToFloatConverter);

}

Hope this helps.
Werner


Am 29.01.2015 um 17:36 schrieb Douwe Doornbos:
> Hello,
>
> I have a form with order-data and several orderlines with an
> amount-field. I want to use a typeconverter to allow both dot and comma
> as decimal separator, but convert both of them to float.
> For the main object I can set a typeconverter in the
> initializeUpdateAction() in the controller:
>
> public function initializeUpdateAction() {
>   $this->arguments['order']
>     ->getPropertyMappingConfiguration()
>     ->forProperty('orderProperty')
>     ->setTypeConverter(new
> \Cmp\Ext\Property\TypeConverter\AmountToFloatConverter);
> }
>
> But how can I set a typeconverter for a property in a child domain
> (orderLine.amount)? I tried initializeUpdateAction() in de orderLine
> controller, but it gets never executed, when i submit the form.
>
> I'm using TYPO3 6.2.9
>
> With kindly regards,
>
> Douwe.
>
> _______________________________________________
> TYPO3-project-typo3v4mvc mailing list
> TYPO3-project-typo3v4mvc at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc
>
>



More information about the TYPO3-project-typo3v4mvc mailing list