Display error messages containing variables when validating forms in CakePHP

J00lz

New Member
I have the $validate variable in my model which contains:\[code\]var $validate=array(\[/code\]"username" => array( "usernameValid" => array( "rule" => "__alphaNumericDashUnderscore", "message" => "The username you entered is not valid!" ) ) );The question is: how do I return an error message from the \[code\]__alphaNumericDashUnderscore()\[/code\] validation method and throw it in the \[code\]message\[/code\] key in the rules array?For example, this method, \[code\]__alphaNumericDashUnderscore()\[/code\], returns true or false, depending on the user input contains forbidden characters. But what if in this method, I would like to return which specific forbidden characters the user has typed and display them together with the \[code\]messages\[/code\]? Something like \[code\]"The username you entered is not valid! You have used the following forbidden characters: $chars"\[/code\].Do you have any idea of how to achieve this? Thank you in advance.
 
Back
Top