Hi,
how to set error message for required form validator? there is a
username element that required is true, then three validators are added to
it.The first is notEmpty validator with message "now allow empty",the second
is stringLength validator with options of array(1,20,'messages'=>'username
must between 1 and 20 characters long'),the third is a custom validator. all
these validator are set breakChainOnFailure. Then i post the form with the
username empty,and the notEmpty error message not display,but stringLength
error messages.If i delete the notEmpty validator,then post the form with
username empty,the default error message for the notEmpty is display.
the code as following:
<?php
// ...
// if post the form with receiver empty,the stringLength validator message
display instead of notEmpty message
$receiver->setRequired(true);
$receiver->addValidator('notEmpty', true, array('messages'=>'not allow
empty')); // if i delete this validator,then post the form with receiver
empty,the default message for the notEmpty validator is display
$receiver->addValidator('stringLength', true, array(1, 20,
'messages'=>'username must between 1 and 20 characters long'));
$receiver->addValidator('checkReceiver', true, array($this->db,
'messages' => 'username exists));
// ...