Zend Framework

Zend_Form addError() is not working correctly

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Not an Issue
  • Affects Version/s: 1.11.3
  • Fix Version/s: None
  • Component/s: Zend_Form
  • Labels:
    None

Description

$form->getElement('nobaru')->addError('My custom error');

if ($form->isValid($this->getRequest()->getPost())) {                
    // OK
} else {
    // Should not be empty array
    $zf = $form->getMessages();
}

getMessages() will return empty array even though the element has been marked as failed, however, the custom error message will be displayed if the element failed another validation defined when creating the element in another class extended from Zend_Form

Issue Links

Activity

Hide
aurorius added a comment -

I don't think the previous issue has been fixed, so, I'm opening new issue for the problem

Show
aurorius added a comment - I don't think the previous issue has been fixed, so, I'm opening new issue for the problem
Hide
Michelangelo van Dam added a comment -

This issue is a non-issue since custom error messages should be retrieved using $form->getErrorMessages().

The only moment $form->getMessages() returns the custom error message is exactly when validation failures occur, which is indeed the case.

Show
Michelangelo van Dam added a comment - This issue is a non-issue since custom error messages should be retrieved using $form->getErrorMessages(). The only moment $form->getMessages() returns the custom error message is exactly when validation failures occur, which is indeed the case.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: