[TYPO3-german] form.select Viewhelper mit property und multiple

g4-lisz at tonarchiv.ch g4-lisz at tonarchiv.ch
Sat Feb 1 13:49:24 CET 2014


On 02/01/2014 12:09 PM, g4-lisz at tonarchiv.ch wrote:
> Hallo Leute,
>
> was kriege ich dann für einen Variablentyp an die Action geliefert, wenn
> ich ein Formular mit einem multiple select auf eine Objekt-Property mache?
>
> Also z.B.
>
> <f:form action="updateMessage" name="message" object="{editMessage}" >
>     <f:form.select size="5" multiple="multiple" property="recipients"
> options="{addresses}" optionLabelField="name"/>
>    ...
> <f:form.submit value="Save" />
>
> Wie muss die Property message.recipients geartet sein? Ist das wie bei
> Checkboxes ein Array aus UIDs?
>
> Grüße,
> Till

Ja, es ist ein Array! Die updateAction sieht daher z.B. so aus:

        /**
         * Sets the recipientsarr
         *
         * @param array recipientsarr
         * @return void
         */
        public function setRecipientsarr($recipientsarr) {
                $addressRepository =
\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('GK\Myapp\Domain\Repository\AddressRepository');
                $newStorage = 
\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Extbase\Persistence\ObjectStorage');
                foreach($recipientsarr as $addressUid)
                       
$newStorage->attach($addressRepository->findByUid($addressUid));
                $this->setRecipients($newStorage);
        }

Closed.


More information about the TYPO3-german mailing list