Zend_Form getErrors
Asked Answered
W

1

5

I have a form.
It's checked: $isValid = $form->isValid($this->getRequest()->getPost())

The problem is errors are empty.
$form->getErrors() returns array {"field1": [], "field2": [], "field3": [], "field4": []} when form is invalid.

So inner arrays are empty. What should I do to find why form is invalid? Code is not developed by me, but there is nothing suspicious in it.

Winslow answered 30/9, 2012 at 2:29 Comment(0)
G
10

You could use $form->getMessages() to get the error messages.

 $form->isValid($this->_getAllParams());
 $form_messages = $form->getMessages();
Gobioid answered 30/9, 2012 at 15:41 Comment(4)
getMessages returns one empty array.Winslow
The problem field is file field.Winslow
$this->getRequest()->getPost() is same as $this->_getAllParams() right?Solmization
No, $this->getRequest()->getPost() returns only POST params. $this->_getAllParams() returns all params, including url params and GET and dynamically added params.Importunity

© 2022 - 2024 — McMap. All rights reserved.