Try to rename your error labels, so they do not conflict with existing error labels!
Change "between" to "username_between" and "unique" to "username_unique", then try again! Hope this helps ;) John On Dec 17, 12:14 pm, pablosky <[email protected]> wrote: > Thanks John. > > But that's my problem. That's what I'm trying and not working. > > My model: > > var $validate = array( > 'username' => array( > 'between' => array( > 'rule' => array('between', 4, 10), > 'last' => true > ), > 'unique' => array( > 'rule' => 'isUnique' > ) > ) > ); > > My view: > > echo $form->input('username', array( > 'error' => array( > 'between' => _('Between 4 and 10.', true), > 'unique' => _('Existing User', true) > ) > ); > > But do not show these error messages. Shown are the error messages by > default. But if I put only an error message then it is displayed. > > echo $form->input('username', array('error' => _('Between 4 and 10.', > true))); > > I do not understand, is documented in the book and in bakery and did > not work. > > Thanks > > On 17 dic, 10:49, John Andersen <[email protected]> wrote: > > > Here is what I do :) > > > Define the validation in the model with a rule name for each > > validation you want to apply to a field, as specified in: > > >http://book.cakephp.org/view/133/Multiple-Rules-per-Field > > > Example: > > 'username' => array( > > 'users_username_rule' => array( 'rule' => array('custom', '/^[a-z] > > {1,}[ a-z0-9]{3,}$/i') ), > > 'users_username_length_rule' => array('rule' => array('between', > > 4,40) ) > > ), > > > In your view, override the model error messages, as specified in: > > >http://book.cakephp.org/view/133/Multiple-Rules-per-Field > > > Example: > > > print( > > $form->input( > > 'username', > > array( > > 'label' => __('user name',true), > > 'error' => array( > > 'users_username_rule' => __('users_username_rule',true), > > 'users_username_length_rule' => __ > > ('users_username_length_rule',true) > > ) > > ) > > ) > > ); > > > Enjoy, > > John > > > On Dec 17, 11:24 am, pablosky <[email protected]> wrote: > > > > Thanks for answering. > > > > I do this because I need to translate the messages of validation. I > > > found this method in the book and also cake "bakers": > > > >http://book.cakephp.org/view/133/Multiple-Rules-per-Field(Intheend)http://bakery.cakephp.org/articles/view/multiple-rules-of-validation-... > > > > How else can I translate the custom messages of validation? > > > > Tranks > > > > On 17 dic, 02:07, peterchenadded <[email protected]> wrote: > > > > > I believe you can only include one default error message using the > > > > form helper. It is not possible to include more than one. Which would > > > > be the reason the 'unique' message is not showing as it is simply > > > > ignored. > > > > > Please see below to get your validation errors working > > > > > In your model: > > > > > var $validate = array( > > > > 'username' => array( > > > > 'between' => array( > > > > 'rule' => array('between', 4, 10), > > > > 'message' => 'username must be between 4 and 10', > > > > 'last' => true, > > > > 'required' => true > > > > ), > > > > 'unique' => array( > > > > 'rule' => 'isUnique', > > > > 'message' => 'username already exists' > > > > ) > > > > ) > > > > ); > > > > > In your view: > > > > > <?php echo $form->input('username'); ?> > > Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
