[Flow] about Feature #37436 (Was: \DateTimeConverter)
mario chiari
ml at mariochiari.net
Fri Nov 15 20:58:47 CET 2013
Bastian, All
sorry to take up this old thread, but I still miss something.
So, we have father/son/toy models, 1:M, 1:M; and
a single New form to create several fathers, several sons for each
father, several toys for each son.
createAction is:
createAction(\Doctrine\Common\Collections\Collection $newFathers) {
foreach($newFathers as $father){
$this->fatherRepository->add($father); }
Now, say I submit several fathers, a SINGLE son for each father, and
several toys for each son. createAction goes thru fine.
Next, let me have SEVERAL sons for each father. Then I get an error msg:
Exception while property mapping for target type "Doctrine\Common
\Collections\Collection<\Mario\Basic\Domain\Model\Father>", at property
path "0.sons": It is not allowed to map property "1".
To fix it, I initializeCreate by
for($i = 0 ; $i < 99 ; $i++){
$this->arguments['newFathers']->getPropertyMappingConfiguration()
->forProperty($i.'.sons.*')
->allowAllProperties()->setTypeConverterOption(
'TYPO3\Flow\Property\TypeConverter\PersistentObjectConverter',
\TYPO3\Flow\Property\TypeConverter
\PersistentObjectConverter::CONFIGURATION_CREATION_ALLOWED, TRUE );}
I am not sure, but it seems to me that
http://forge.typo3.org/issues/37436 is not working (was not intended to
work?) for the first level of nesting, if I try to submit several first
level items.
Help to clarify is very welcome
thanks
mario
On Fri, 2013-06-21 at 12:06 +0200, Bastian Waidelich wrote:
> 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
>
More information about the Flow
mailing list