Hi,

I have text element in the form with two validators
+-------------------------------------------------------------------
        $mytext= New Zend_Form_Element_Text('mytext');
        $mytext->setLabel('Enter Text:');
        $mytext->setAttrib('size', '40');
        $mytext->setRequired(true);
        $mytext->addFilter('StringTrim');
        $mytext->addValidator('NotEmpty');
        $mytext->addValidator('Alnum');
+-------------------------------------------------------------------
I tried general error message to this text element like this:

$mytext->addErrorMessage('Invalid Text');

but when I try to submit the form without entering a thing, this error
message is displayed twice.

After that I tried:

        $mytext->addErrorMessages(array('NotEmpty' => 'String cannot
be empty', 'Alnum' => 'Invalid string'));

Hoping this will assign the specific error to each validator, but when
I submit the empty form, now it displays the message four times.

What I actually wanted to do is:
*****************************************
Empty string will be checked first and shown error message ignoring
other validators. So if the string is empty show the error message for
empty string validator and exit from validator chain ignoring other
validators in the sequence. But it seems all validators are active
each time.
*****************************************
1. how do I do that?
plus
2. how to set the error message for specific validator so that only
that message will get displayed instead of all the error message


Thanks


-- 
=======================
Registered Linux User #460714
Currently Using Fedora 8, 10
=======================

Reply via email to