[TYPO3-dev] Populating form select options in fluid

Heinz Müller mullerheinz046 at gmail.com
Tue Mar 25 20:57:07 CET 2014


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
>



More information about the TYPO3-dev mailing list