[TYPO3-dev] Populating form select options in fluid

Richard Achatz info at richardachatz.de
Thu Mar 27 23:09:38 CET 2014


Hi Heinz,

Im still intrested wether <f:debug {HARDCODEDARRAY}> and <f:debug {ARRAYFROMCONTROLLER}> producing exactly the Same output?



Caspar Stuebs <caspar at gosign.de> schrieb:
>Hi Heinz,
>
>I have tested this matter and I can't reproduce it.
>I guess, that the problem is produced somewhere else in your code.
>
>Have you tried to get the selectbox within a controller and template,
>with
>nothing else then the selectbox?
>
>Which TYPO3 version are you using, have you tried to use another one?
>
>Maybe you could provide the whole controller and template code to have
>a
>look on it?
>
>Kind Regards.
>Caspar
>
>
>2014-03-27 11:36 GMT+01:00 Heinz Müller <mullerheinz046 at gmail.com>:
>
>> Hi Florian,
>>
>> thanks for your suggestion. I just tried exactly this but it fails,
>too.
>>
>> Interestingly, the documentation at
>http://wiki.typo3.org/Fluid#f:formonly
>> discusses the following two uses of the view helper:
>>
>> Supply an associative array:
>> <f:form.select name="paymentOptions" options="{payPal: 'PayPal',
>visa:
>> 'Visa Card'}" />
>>
>> Via getter methds of a domain object:
>> <f:form.select name="users" options="{userArray}"
>optionValueField="id"
>> optionLabelField="firstName" />
>>
>> But according to the source code in SelectViewHelper it should work
>with a
>> simple associative array:
>> $this->registerArgument('options', 'array', 'Associative array with
>> internal IDs as key, and the values are displayed in the select box',
>> TRUE);
>>
>> Anyways, I'm still in the dark.
>> Heinz
>>
>>
>>
>>
>> On Wed, Mar 26, 2014 at 10:45 AM, Florian Rival <contact at oktopuce.fr>
>> wrote:
>>
>> > Hi Heinz,
>> >
>> > Have you simply try something like this :
>> >
>> >
>> > $options = array();
>> > $options['foo'] = 'bar';
>> > $this->view->assign('options', $options);
>> >
>> > <f:form.select name="myOptions" options="{options}" />
>> >
>> > Because if you use the 'property' attributes, the view helper tries
>to
>> > find an object with a getter method.
>> >
>> > It should work, just have a look at the fluid documentation :
>> > http://wiki.typo3.org/Fluid#f:form
>> >
>> > You can also have a look in the PHP file of the Form ViewHelper to
>see
>> all
>> > arguments :
>> >
>> > "typo3/sysext/fluid/Classes/ViewHelpers/FormViewHelper.php"
>> >
>> > Regards,
>> > Florian
>> >
>> >
>> > Le 25/03/2014 20:57, Heinz Müller a écrit :
>> >
>> >  Thanks for your help.
>> >>
>> >> @Richard: The debug output is not the problem. The variable
>$options is
>> >> set
>> >> and filled with the correct values.
>> >>
>> >> @Sebastian: I have tried using an associative array, same result.
>> >>
>> >> Well, I guess it is simply not possible to use associative arrays
>in the
>> >> SelectViewHelper unless it's a domain object with getters for
>value and
>> >> label to use something like this in the view:
>> >> <f:form.select property="myProperty" options="{options}"
>> >> optionValueField="foo" optionLabelField="bar" />
>> >>
>> >> Any comments on whether my previously mentioned alternative
>approach
>> using
>> >> objects could actually be made to work?
>> >> http://docs.typo3.org/typo3cms/ExtbaseGuide/Fluid/
>> >> BestPractice/OptionsForSelect.html
>> >>
>> >> I tried it and it did not work either.
>> >>
>> >> Regards,
>> >> Heinz
>> >>
>> >>
>> >>
>> >> On Tue, Mar 25, 2014 at 8:21 AM, Sebastian Fischer
><typo3 at evoweb.de>
>> >> wrote:
>> >>
>> >>  Hi Heinz,
>> >>>
>> >>> did you try to use an associated array?
>> >>>
>> >>> $options = array();
>> >>> $options['foo'] = 'bar';
>> >>>
>> >>> $this->view->assign('options', $options);
>> >>>
>> >>> I think the select vierhelper needs to have value and label to
>render
>> it.
>> >>>
>> >>> Greetings
>> >>> Sebastian
>> >>>
>> >>> Am 24.03.2014 21:08, schrieb Heinz Müller:
>> >>>
>> >>>   Hi all,
>> >>>
>> >>>> I want to populate the options of a select box with data in my
>> extension
>> >>>> but it doesn't work.
>> >>>>
>> >>>> In my controller:
>> >>>>
>> >>>> $options = array();
>> >>>> $options[] = 'foo';
>> >>>> $options[] = 'bar';
>> >>>> $this->view->assign('options', $options);
>> >>>>
>> >>>> In fluid:
>> >>>> <f:form.select property="myProperty" options="{options}"/>
>> >>>>
>> >>>> But my select box remains empy. The only way I can assign values
>is
>> >>>> explicitly through (options="{foo: 'bar'}") but I want to
>generate the
>> >>>> contents from my controller, not hardcoded in my view.
>> >>>>
>> >>>> <f:debug>{_all}</f:debug> shows that $options exists and that it
>has
>> the
>> >>>> desired contents.
>> >>>>
>> >>>> I have also tried to fill the array with objects according to
>this
>> >>>> article:
>> >>>> http://docs.typo3.org/typo3cms/ExtbaseGuide/Fluid/
>> >>>> BestPractice/OptionsForSelect.html
>> >>>> but this did not help either.
>> >>>>
>> >>>> What am I doing wrong?
>> >>>>
>> >>>> Thanks for any hints,
>> >>>> Heinz
>> >>>>
>> >>>>
>> >>>>  _______________________________________________
>> >>> TYPO3-dev mailing list
>> >>> TYPO3-dev at lists.typo3.org
>> >>> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-dev
>> >>>
>> >>>  _______________________________________________
>> >> TYPO3-dev mailing list
>> >> TYPO3-dev at lists.typo3.org
>> >> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-dev
>> >>
>> >>
>> > --
>> > Re: [TYPO3-dev] How to call Extbase controller action from
>piBase-Plugin?
>> >
>> > ==================================================
>> > Florian Rival
>> > Oktopuce
>> > tel.: +33-642-255-448
>> > fax : +33-985-375-102
>> > web: www.oktopuce.fr
>> > ==================================================
>> >
>> >
>> > _______________________________________________
>> > TYPO3-dev mailing list
>> > TYPO3-dev at lists.typo3.org
>> > http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-dev
>> >
>> _______________________________________________
>> TYPO3-dev mailing list
>> TYPO3-dev at lists.typo3.org
>> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-dev
>>
>
>-- 
>-- 
>
>Gosign media. GmbH | We web ideas.
>Langenfelder Damm 67 Gewerbehof | 22525 Hamburg
>Telefon 040-609 40 79-0
>
>Handelsregister AG HH HRB 112197 | Geschäftsführung Bert Gogolin
>Greenpeace energy: Gosign läuft mit ehrlichem Strom und Gas.
>GLS Bank: Gosign wirtschaftet mit Gewissen. 
>_______________________________________________
>TYPO3-dev mailing list
>TYPO3-dev at lists.typo3.org
>http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-dev

-- 
Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail gesendet.Email sent using Axigen Free Mail Server:
http://www.axigen.com/mail-server/free


More information about the TYPO3-dev mailing list