Hi,

I am currently having a problem with validating Zend_Form. Everything works great except when I try to add a NotEmpty validator to a field which is required.

$username = new Zend_Form_Element_Text('username');
$username->setLabel('Username')
         ->setRequired(true);

behaves as expected. Now I needed to change the message returned by the validator:

$valNotEmpty = new Zend_Validate_NotEmpty();
$valNotEmpty->setMessage("Message or whatever");

$username = new Zend_Form_Element_Text('username');
$username->setLabel('Username')
         ->setRequired(true)
         ->addValidator($valNotEmpty);

This returns exception 'Validator instance already exists for validator "NotEmpty"' no matter whether I set it before or after the setRequired() call.

Tried on 1.7.0 and 1.7.4. Any ideas on what is wrong?

Thanks

Jan Brucek

Reply via email to