Comments

Assigning to Thomas. Thomas, make sure the decorators are using getFullyQualifiedName().

Posted by Thomas Weidner (thomas) on 2009-02-23T13:42:44.000+0000

@G.:
I just verified but I can't get your results.
When I name the file element "image_src" the rendered element is also named "image_src" and not "image".

Related to the sub_form notation:
This is nothing which can be done for file elements.

The problem arises when you use Sub-Sub-Forms, or deeper nesting, or when you use multifiles with Sub-Forms. PHP then brakes the Sub-Form notation into something unreadable.
For example a file within a 3 level nested Sub-Form would be named "subform3[subform2][subform1][subform0][image_src]".
But the resulting $_FILES array is
Array ([subform3] => Array ([name] => Array ([subform2] => Array ([subform1] => Array ([subform0] => Array ([image_src] => filename))))
As the resulting name is broken in multiple sub arrays the upload is broken.

This is within PHP itself a not defined behaviour. And this behaviour is different depending on the used PHP version. Therefor we change the naming of file elements to match the accepted PHP naming notation.

With the actual PHP releases there is no known solution to this problem as it's simply not defined.

This is not a bug, this is wished behaviour and I think it's also documented.

Posted by G Cohen (untitled4) on 2009-02-23T15:02:55.000+0000

Thank you for responding so quickly.

The first "issue" is my own fault as I was trying to simplify the code for this report and got it wrong. I do get image_src as the element name.

The issue I was addressing is that I am expecting the file element to be name "image_form['image_src]" (if my sub form is named image_form) and for it to be part of the sub form array when I request the form data when I process it. This is (simplified again) what I am expecting:

but $image_form does not contain the data (file name) from the file element, so what I have to do ($main_form is my main form):
$image_form = $main_form->getSubForm('image_form');
$image_data = $image_form->getValues();

I only have one sub form to main form (I'm not so ambitious as to have sub forms nested in sub forms).

Obviously, it's not a big deal and the workaround doesn't require a lot of work, but I still think it is a bug as I was expecting it to behave in the same way as other sub form elements but it and I think the idea of array notation is very useful, but not if the file element is missing from it.

If it's impossible for the file element to be added to the array notation in sub forms then I think the documentation (http://framework.zend.com/manual/en/…) should be changed to reflect that.