View Single Post
  #1 (permalink)  
Old 02-11-2008, 02:23 PM
greboguru's Avatar
greboguru greboguru is offline
Junior Member
 
Join Date: Feb 2008
Location: UK
Posts: 16
Question Zend Form - Custom Errors ... how?

Hi,

I'm trying to add a custom error message to my form defintion, but all I'm getting are the default messages.

My definition ..

Code:
 
   var $form = array(
       'action'   => '/myswr/site/admin/login',
       'method'   => 'post',
       'elements' => array(
           'username' => array('text', array(
               'validators' => array(
                   array('alnum', array('message' => '%s must be alphanumeric!')),
                   array('regex', false, array('/^[a-z]/i')),
                   array('stringLength', false, array(3, 20,
                                          'message' => array(
                                          	Zend_Validate_StringLength::TOO_SHORT => '%s must be at least %min% characters.',
                                          	Zend_Validate_StringLength::TOO_LONG => '%s must be shorter than %max% characters.'))
                   )
               ),
               'required' => true,
               'filters'  => array('StringToLower')
           )),
           'password' => array('password', array(
               'validators' => array(
                   array('stringLength', false, array(3))
               ),
               'required' => true,
           )),
           'submit' => 'submit',
       ),
   );
Where am I going wrong? I've seen examples on how do this 'long hand' but I can't seem to get the above to work ?

Thanks!
Reply With Quote