do it form view:
http://book.cakephp.org/view/204/Form-Element-Specific-Methods#error-721
- $form->input() has 'error' option too
- you can create virtual validation filed and invalidate it form
Model::beforeValidate()
example:
$validate= array(
'password_too_short'=>'checkPasswordLenghtMethod'
'password'=>'notEmpty'
)
and in view:
echo $form->input('password');
echo $form->error('password', 'Please enter password');
echo $form->error('password_too_short', 'Password is too short. Please
enter...');
(I think this should work...)
On Aug 15, 8:11 pm, jordicakephp <[email protected]> wrote:
> Good afternoon everybody,
>
> I would like the custom validation functions of my models to return
> different error messages, depending on what the user has sent. That
> is, to define these messages not in compilation time, but during the
> execution of the model's logic.
>
> I've tried to to that in the beforeValidate() method of the model,
> when defining my validation rules, with the help of $errorMessage (a
> class variable):
>
> 'rule' => 'myCustomRule',
> 'message' => $this->errorMessage.
>
> Then, as I say, I manipulate the content of $this->errorMessage inside
> myCustomRule, depending on what the user writes. But it doesn't
> work... :-(
>
> Could somebody please give me a clue about how to define many error
> messages for just one custom rule? Thanks a lot in advance for your
> help! :-)
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---