views:

133

answers:

1

Hi,

I'm using Zend_Filter_Input to sanitize input from a registration process. My code looks like so:

$validators = array(
     'user_id'=> array(
       array('Alnum', TRUE),
       'NotEmpty',
       'presence' => 'required',
             'messages'=>array('Your username can contain only alphabetic or numeric letters, and must be between 3 and 20 characters.'),
       array('StringLength', 3, 20)
      ),
'first_name'=>array(
       array('Alpha', TRUE),
       'NotEmpty',
       'presence' => 'required',
      'messages'=>array('Your first name can contain only contain alphabetic letters, and must be between 3 and 20 characters.'),
       array('StringLength', 3, 20)
      ),

I'd like to customize the error messages Zend returns so that if any one of the filter's fail, it displays the text under 'messages'. Right now its displaying its own error messages when the 'NotEmpty', 'Presence' or StringLength conditions are met, and only displays my message when the 'Alnum' filter fails. How can I get it to display only my message when any of the conditions are met?

Thanks.

A: 

This might be related to a regression bug that affected Zend Framework 1.8, which was reported resolved in ZF 1.9.3 (specifically revision 17845).

http://framework.zend.com/issues/browse/ZF-7394

Bill Karwin