cakePHP“必需”验证

发布于 2024-09-07 14:08:04 字数 443 浏览 1 评论 0原文

这个验证有什么错误吗???

 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

七颜 2024-09-14 14:08:04

您缺少一个规则,仅仅required 是不行的。如果您想要的话,请使用 'notEmpty' 作为规则。另外,requiredmessage 应该(必须?)不是数组。

You're missing a rule, just required won't do. Use 'notEmpty' as rule if that's what you want. Also, required and message should (must?) not be arrays.

も星光 2024-09-14 14:08:04

为什么到处都有数组?

 var $validate = array(
  'brand_id' => array(
   'required' => true,
   'message' => 'select a brand',
  )
);

参考:
http://book. cakephp.org/1.3/en/The-Manual/Common-Tasks-With-CakePHP/Data-Validation.html

Why do you have arrays everywhere?

 var $validate = array(
  'brand_id' => array(
   'required' => true,
   'message' => 'select a brand',
  )
);

Refer to:
http://book.cakephp.org/1.3/en/The-Manual/Common-Tasks-With-CakePHP/Data-Validation.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文