Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.10.4
-
Fix Version/s: 1.10.6
-
Component/s: Zend_Validate_File
-
Labels:None
Description
If use upload multifile (eg 3) and upload only "file_2" and set option "ignoreNoFile => true", after validate "file_1" for files "file_2", "file_3" etc, other validators be ignored.
Reproduction:
$this -> setMethod('post');
$this -> setAttrib('enctype', 'multipart/form-data');
// Images elements
$element = new Zend_Form_Element_File('file');
$element -> addValidator('Count', false, array(
'min' => 1, 'max' => 3
));
$element -> addValidator('MimeType', false, 'image/png');
$element -> setDestination(
realpath(APPLICATION_PATH . '/../public/uploads/images'
));
$element -> setMultiFile(3) -> setValueDisabled(true);
$this -> addElement(
$element
);
I fix this in Zend_Validate_File_Upload method isValid, replace "$this->_value = $file;" to "$this->_setValue($file);" for clean "$this->_messages"
The "ignoreNoFile" option can only be set on elements/files.
A multifile is a file which consists of several parts (where luckily each part is a file itself).
This means "ignoreNoFile" is set on the multifile, not on a part of this multifile. This is no bug but wished behaviour.
When you want to have several independend files then use multiple file elements instead of the multifile feature.