ZF-11152: Zend_Form_Element_File::getFileName() returns array if empty
Description
The following code makes getFileName return an empty array.
if($form->isValid($formData)){
$uploadedData = $form->getValues();
$element = new Zend_Form_Element_File("element_name");
$fileName = $element->getFileName();
}
This is when the no file is supplied and element has setValueDisabled(true) in the form and it's not set to required. The documentation says Zend_Form_Element_File::getFileName() is to return a string.
Comments
Posted by Adam Lundrigan (adamlundrigan) on 2011-04-30T07:36:22.000+0000
I'm fairly confident this type of change would be considered a BC break. A return type of array() when no file fields with the specified name were uploaded is not ideal, but nonetheless is acceptable. The documentation should be updated to make note of the current behavior of getFileName() - here is my take on how that could be done:
The PHP function empty() treats empty strings, null and array() the same - empty. So, to find out if no files were returned you do: empty($element->getFileName()). This will cover off all the ways getFileName() could report that there are no files.
Posted by Thomas Weidner (thomas) on 2011-05-01T07:03:06.000+0000
Reassigning to component author
Posted by Adam Lundrigan (adamlundrigan) on 2011-05-03T14:05:19.000+0000
Patch applied to trunk r23963
Posted by Thomas Weidner (thomas) on 2011-05-03T14:26:44.000+0000
Adam, thnx for your fix
Please do actually not close this issue as this component is being reworked. This is intentionally Thnx
Posted by Adam Lundrigan (adamlundrigan) on 2011-06-24T15:44:35.000+0000
Merged documentation change to release-1.11 in r24153
Posted by Adam Lundrigan (adamlundrigan) on 2012-05-18T12:13:17.000+0000
Thomas: Is it safe to close this issue now?