[TYPO3-mvc] New Property Mapper / persisting nested form objects

Alexander Dick typo3 at dick.at
Fri Jan 27 11:23:57 CET 2012


That is exactly how I did it now, I also made for-loop.

Thanks again!

best regards
Alex

Am 27.01.2012 10:23, schrieb Tim Schoch | GSTALTIG:
> Hi Alex
>
> Yep, but that works well only if you know how many objects there are. I extended that code a little to handle an unknown amount.
> This is the final code:
>
> protected function initializeCreateUpdateAction() {
> if ( $this->request->hasArgument( 'foo' ) ) {
>        $foo = $this->request->getArgument( 'foo' );
>        $count = count( $foo['datas'] );
>        $this->arguments['foo']->getPropertyMappingConfiguration()->allowCreationForSubProperty('datas');
>        $this->arguments['foo']->getPropertyMappingConfiguration()->allowModificationForSubProperty('datas');
>        for( $i = 0; $i<  $count; $i++ ) {
>          $this->arguments['foo']->getPropertyMappingConfiguration()->allowCreationForSubProperty('datas.'. $i );
>          $this->arguments['foo']->getPropertyMappingConfiguration()->allowModificationForSubProperty('datas.'. $i );
>        }
>      }
> }
>
> This again works only if the POST arguments are numbered sequential «0, 1, 2, ... N».
> However it will fail if the key is for example the uid or a string.
> Tim
>
> Tim
>    _____
>
> From: Alexander Dick [mailto:typo3 at dick.at]
> To: typo3-project-typo3v4mvc at lists.typo3.org
> Sent: Fri, 27 Jan 2012 10:01:03 +0100
> Subject: Re: [TYPO3-mvc] New Property Mapper / persisting nested form objects
>
> Am 26.01.2012 21:44, schrieb Tim Schoch | GSTALTIG:
>    >  I had the same Problem some time ago:
>    >  http://lists.typo3.org/pipermail/typo3-project-typo3v4mvc/2011-September/010370.html
>    >  Unfortunatly that thread ends without the final solution. I'll have to look how I did it when I'm back at work tomorrow.
>    >  Tim
>    >
>    >  PS: Hint to google only the mailing list: site:http://lists.typo3.org/pipermail/typo3-project-typo3v4mvc foo
>
>    Hi Tim!
>
>    I think I found how you solved the problem back then:
>
>    ->allowCreationForSubProperty('datas.0');
>
>    http://lists.typo3.org/pipermail/typo3-project-typo3v4mvc/2011-September/010386.html
>
>    Though it's an ugly workaround - it also works for me - thanks a lot!
>
>    kind regards
>    Alex
>
>    _______________________________________________
>    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