cakePHP“必需”验证
这个验证有什么错误吗???
var $validate = array(
'brand_id' => array(
'required' => array(true),
'message' => array('select a brand'),
)
);
brand_id是一个选择框
它将错误显示为“消息”而不是“选择品牌”
如果消息不在数组中,则
Warning (2): preg_match() [function.preg-match]: Delimiter must not be alphanumeric or backslash [CORE\cake\libs\model\model.php, line 2571]
使用 cakePHP 1.3显示错误
is there any mistake in this validation???
var $validate = array(
'brand_id' => array(
'required' => array(true),
'message' => array('select a brand'),
)
);
brand_id is a select box
It show error as "message" instead of "select a brand"
if the message is not in array it shows error
Warning (2): preg_match() [function.preg-match]: Delimiter must not be alphanumeric or backslash [CORE\cake\libs\model\model.php, line 2571]
using cakePHP 1.3
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您缺少一个规则,仅仅
required
是不行的。如果您想要的话,请使用'notEmpty'
作为规则。另外,required
和message
应该(必须?)不是数组。You're missing a rule, just
required
won't do. Use'notEmpty'
as rule if that's what you want. Also,required
andmessage
should (must?) not be arrays.为什么到处都有数组?
参考:
http://book. cakephp.org/1.3/en/The-Manual/Common-Tasks-With-CakePHP/Data-Validation.html
Why do you have arrays everywhere?
Refer to:
http://book.cakephp.org/1.3/en/The-Manual/Common-Tasks-With-CakePHP/Data-Validation.html