typo3fluidtypo3-7.6.x

How to access variable keys in an associative array in fluid?


I assign an associative array values to my view in the action controller.

<f:debug>{values}</f:debug> outputs the following, which means, the data is in the view.

array (3 items)
    63 => 158 (integer)
    49 => 0 (integer)
    164 => 0 (integer)

In my fluid template I have a loop over some items. In that loop, I create select fields with the f:form.select viewhelper. The form is not bound to an object, I can not use the property argument. But I want to reflect the current (last selected) value of each of the select fields.

Each select is named filter_{loopItem.uid}.

<f:debug>{values.63}</f:debug> outputs 158 (integer) which is correct, too. If I set value={values.63} in the value argument of the f:form.select viewhelper, the corresponding option is selected in filter_63.

What I want to do, is use the uid as index for the filters array, so that I can write something like value={values.{loopItem.uid}} and the select selects the corresponding option. But this does not work, debug outputs NULL.

{values.63} with a constant 63 works fine. Even an alias mapped {index: loopItem.uid} with {values.index} results in NULL.

How can I substitute the fixed 63 by a variable value based on the loopItem.uid?


Solution

  • This is only possible out of the box with TYPO3 8 or you can try VHS https://viewhelpers.fluidtypo3.org/fluidtypo3/vhs/5.0.1/Variable/Get.html