it seem that each validation for the file elements in the zend_form would
validate all of the file elements in the form.it means that if there have
two file elements in the form,says A and B. So isValid() for the element A
is called,it would validate A and B,not just A.
So if i want to upload two files, one is option, and another is
required,then would result in error if i left the option one empty.
do you understand me? if you don't , try the following:
<?php
$form = new Zend_Form();
$form->setEnctype(Zend_Form::ENCTYPE_MULTIPART);
// file a,optional
$a = new Zend_Form_Element_File('A');
$a->setLabel('file a');
$form->addElement($a);
// file b,required
$b = new Zend_Form_Element_File('B');
$b->setLabel('file b');
$b->setRequired(true);
$form->addElement($b);
if ($this->_request->isPost()) {
if ($form->isValid($_POST)) {
echo 'valid';
} else {
echo 'invalid';
}
}
echo $form;