【发布时间】:2010-08-29 13:19:35
【问题描述】:
我的模型中有 $validate 变量,其中包含:
var $validate=array(
"用户名" => 数组( “用户名有效” => 数组( "规则" => "__alphaNumericDashUnderscore", "message" => "您输入的用户名无效!" ) ) );
问题是:如何从__alphaNumericDashUnderscore()验证方法中返回错误信息,并将其扔到规则数组中的message键中?
例如,__alphaNumericDashUnderscore() 这个方法返回真或假,这取决于用户输入是否包含禁止字符。但是,如果在这种方法中,我想返回用户输入了哪些特定的禁止字符并将它们与messages 一起显示呢?类似"The username you entered is not valid! You have used the following forbidden characters: $chars"。
您知道如何实现这一目标吗?提前谢谢你。
【问题讨论】:
标签: php cakephp validation