[Flow] How to build One-To-Many Forms

Axel Wüstemann awu at qbus.de
Mon Nov 4 16:43:30 CET 2013


> How do you define your createAction?
> For a form  to create a inspection (father) and its five (or any N)
> deposits (sons), you may need to initialize the
> deposit_inspection/createAction by something like:
>
>             public function initializeCreateAction()
> { $this->arguments['newInspection']->getPropertyMappingConfiguration()->forProperty('deposits.*')->allowAllProperties()->setTypeConverterOption(
> 'TYPO3\Flow\Property\TypeConverter\PersistentObjectConverter',
> \TYPO3\Flow\Property\TypeConverter
> \PersistentObjectConverter::CONFIGURATION_CREATION_ALLOWED,TRUE); }
>
> Then you should be able to create everything by just
> $this->inspectionRepository->add($inspection);
>

Mario, I run in the error:

  Property "deposit" was not found in target object of type 
"XXX\Intranet\FisheryInspection\Domain\Model\DepositInspection"

When I set a var_dump in the initializeCreateAction
\TYPO\Flow\var_dump($this->arguments['newDepositInspection']->getPropertyMappingConfiguration());
die;

I get my values - but instead of deposits I have deposit:

propertiesToBeMapped => array(8)
    'fast' (4) => 'fast' (4)
    'depositHarbour' (14) => 'depositHarbour' (14)
    'fisheryBadge' (12) => 'fisheryBadge' (12)
    'nationality' (11) => 'nationality' (11)
    'length' (6) => 'length' (6)
    'kindOfTarget' (12) => 'kindOfTarget' (12)
    'deposit' (7) => 'deposit' (7)  <==================
    'statementNote' (13) => 'statementNote' (13)

In the subProprtyMapping

propertiesToBeMapped => array(2)
     'deposit' (7) => 'deposit' (7)
     'amount' (6) => 'amount' (6)

Seemed to me correctly.

Here is some code on pastebin:

The form:

http://pastebin.com/UW1HwReu

initiazeCreateAction:

http://pastebin.com/YRwdkjUS

createAction:

http://pastebin.com/zm9naCjw



More information about the Flow mailing list