Hi,

i have found that Zend_Form_Element_File ignore no file option would not
work if the form that submited is missing that file element.

let's say,there is a form that upload a file to the server,

<form enctype="multipart/form-data" action="/demo/upload" method="post">

any text:<input type="text" name="any" /> <br />

upload file:<input type="file" name="uploadFile" /><br />

<input type="submit" value="upload" />

</form>



and the Zend_Form as this,

<?php

class DemoController extends Zend_Controller_Action

{

public function uploadAction() {

$form = new Zend_Form();
$any = new Zend_Form_Element_Text('any');
$form->addElement($any);

$uploadFile = new Zend_Form_Element_File('uploadFile');
$uploadFile->setAllowEmpty(true);
$form->addElement($uploadFile);

if ($this->_request->isPost() && $form->isValid($_POST)) {
 echo 'valid';
}

}

}


then submit the form,that is ok.But if submit the form as this,it is not valid,

<form enctype="multipart/form-data" action="/demo/upload" method="post">

any text:<input type="text" name="any" /> <br />

<input type="submit" value="upload" />

</form>

this form just missing the file element,<input type="file"
name="uploadFile" />,but i had set the Zend_Form to allow empty
file,ignore no file option.


I think this should be a bug. Right?


Best Regards

Reply via email to