ZF-9847: $form->isValid($request->getPost()) doesn't seem to work when zend file element is used



I have created webform using Zend_Form. I post the form and validate it using $form->isValid($request->getPost()). Problem is when i add Zend_File element and posts the form, then isValid return false, but doesn't show any error. I don't know what I am missing. I have seen over different forums as well, but no luck.… provides a solution, but this is for zend 1.5 and things have changed a lot after 1.5 Do I have to work out similar functionality by overriding isValid function? Here is the code:

Form //Add upload Logo element $logo = new Zend_Form_Element_File('logo'); $logo->setLabel('Upload Logo:'); $logo->setDecorators($this->fileElementDecorators); $logo->setRequired(true); $logo->setValueDisabled(true);

$logoPath = BASE_PATH.'/publisher-logos';


// ensure only 1 file $logo->addValidator('Count', false, 1);

// limit to 100K $logo->addValidator('Size', false, 102400);

// only JPEG, PNG, and GIFs $logo->addValidator('Extension', false, 'jpg,png,gif');


Controller if ($this->getRequest()->isPost()) { if($form->isValid($request->getPost())) { //If form is valid } else { echo '

'; print_r($form->getMessages()); echo '

'; exit(); } }

Problem Nothing happens if I provide valid input for file element. isValid() return false if I provide valid input for file element. Please, help me as I am consistently googling this issue!

Thanks, Nabeel


<?php echo $form->render(new Zend_View());?>

Very nice example! Problem has been fixed! Thanks a ton! Really appreciate your prompt response.

I am french... sorry for my bad english... You may forgot the enctype attrib!!!

$form->setAttrib('enctype', Zend_Form::ENCTYPE_MULTIPART);