1
votes

How to remove Zend Form error mesessages (Value is required and can't be empty) ?

3
You need to remove error decorators or validators. - Florent
I need to remove this message Value is required and can't be empty - Defense
But you want to keep other messages? If no, remove the error decorator. If yes, remove the required attribute. - Florent

3 Answers

2
votes
$element->setRequired(false);
1
votes

You can try this:

$yourElement->removeDecorator('Errors'); 
0
votes

You can overwrite error messages in the form like in this example:

    $this->addElement('text', Model_User_Object::USERNAME, array(
        'filters' => array('StringTrim', 'StringToLower'),
        'validators' => array(
            array('notEmpty', true, array(
                    'messages' => array(
                        'isEmpty' => 'YOU CAN WRITE WHATEVER MESSAGE YOU WANT HERE.'
                    )
                )
            )
        ),
        'required' => true,
        'class' => 'input',
        'label' => 'Your username:',
    ));