I apologize if this is the wrong place to post this, but I cant find where
the applicable place would be.

In my experimentation with Zend_Form, I have found a possible bug or simple
lack of knowledge(myself) with Zend_Form::addValidator() or
Zend_Validate_StringLength

Example Code:
-----------------------------------------------------------------------------
//Create Validator
$validator = new Zend_Validate_StringLength(1,5);
$validators->setMessage("Custom Error");

//Create Form Element
$formElement = new Zend_Form_Element_Textarea('description');
$formElement->setLabel('Name')
                     ->addValidator($validator);
----------------------------------------------------------------------------

When processing this Zend_Form_Element with data that is less than one
character long (0), the custom error message "Custom Error" is shown, but if
the data is greater than 5 characters the default Zend_Validate_StringLength
message is shown.

I was under the assumption that the
Zend_Validate_StringLength::setMessage($customMessage, null) set all the
error messages of the validator to the $customMessage. It appears I am
wrong(1*) or there is a bug(2).

I understand that I can pass in an array with the message constants
Zend_Validate_StringLength::TOO_LONG etc..., but it gets redundant, so is
there a way to set all messages of a validator in a single instance?

Can anyone set me straight on this?

Thanks,

Brandon
-- 
View this message in context: 
http://www.nabble.com/Zend_Form-%7C-Zend_Validate_StringLength%3A%3AsetMessage%28%29-Bug--tp15013739s16154p15013739.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to