Issues

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

Issue Type: Bug Created: 2010-05-17T07:08:03.000+0000 Last Updated: 2010-10-16T09:43:51.000+0000 Status: Resolved Fix version(s): - 1.10.5 (26/May/10)

Reporter: Nabeel Mushtaq (nabilmushtaq) Assignee: Thomas Weidner (thomas) Tags: - Zend_Form

Related issues: Attachments:

Description

Hi,

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. http://akrabat.com/php/… 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';

$logo->setDestination($logoPath);

// 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');

$this->addElement($logo);

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

Comments

Posted by Thomas Weidner (thomas) on 2010-05-17T12:22:33.000+0000

render(new Zend\_View());?>

Posted by Nabeel Mushtaq (nabilmushtaq) on 2010-05-18T08:28:51.000+0000

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

Posted by TRIBOULAT Yann (yann05) on 2010-10-16T09:43:51.000+0000

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

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

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts