Hi,I didn't tested it, but I think in your case, you should use
$username->setAutoInsertNotEmptyValidator(false)
or you can if you want to add a message to an already existing validator you
should use:
$username->getValidator('NotEmpty')->setMessage("Message or whatever");
--
Pagarbiai,
Vladas Diržys
Tel.: +370 620 69020
www.dirzys.com
On Tue, Feb 10, 2009 at 11:16 AM, Jan Brucek <[email protected]> wrote:
> 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
>