Issue Bug Closed

#81597property attribute of form input field viewhelper breaks f:for each loop

Michael Stopp 06/16/17, 17:10 updated 10/02/18, 11:00

Description

While migrating a project with a large Fluid form from 6.2 to 8.7, I noticed that some of my loops (e.g. to iterate over child objects) would only print the first child element. This code used to work in 6.2:

<f:for each="{film.director}" as="director" iteration="i">
    {director.uid}: <f:form.textfield property="director.{i.index}.firstName" /><br>
</f:for>

Let’s say the output for this was:

12: John
37: Anna

In 8.7 the output for the same code is:

12: John

I first thought it was a problem with the iterator variable. But even if I do this (which doesn’t make sense of course), it doesn’t work (i.e. there will only be one iteration of the loop):

<f:for each="{film.director}" as="director" iteration="i">
    {director.uid}: <f:form.textfield property="director.0.firstName" /><br>
</f:for>

When I avoid the property attribute, it does work:

<f:for each="{film.director}" as="director" iteration="i">
    {director.uid}: <f:form.textfield name="tx_cudist_myfilms[film][director][{i.index}][firstName]" value="{director.firstName}" /><br>
</f:for>

I only got the property attribute to work inside a loop, when I used the VHS iterator viewhelper:

<v:iterator.for from="0" to="1" iteration="i">
    {film.director.{i.index}.uid}: <f:form.textfield property="director.{i.index}.firstName" /><br>
</v:iterator.for>

FYI: I first encountered this problem in the context of a viewhelper for FAL upload fields. My viewhelper is based on Helmut Hummel’s sample project (https://github.com/helhum/upload_example) for file uploads. When I commented out the call to $this->getValueAttribute(); in the viewhelper class, the f:for loop wouldn’t break anymore (but it obviously broke the viewhelper…).

Reviews 2