我在模型中的验证数组中有语法错误。如果我在控制器中编写相同的代码
,那就没关系$validation = array(
'field' => array(
'required' => array(
'rule' => 'notEmpty',
'message' => 'field Can not be empty!'
),
'validRange' => array(
'rule' => array('comparison', '>', __('MAX_RANGE'))), //here is the syntax error. MAX_RANGE is a constant which is define in language file
'message' => 'field cant not be greater than maximum range'
)
)
)
答案 0 :(得分:0)
如果你遇到这些错误,我也会建议你开始这个错误。
这是
字段将包含数组
'field' => array(
'required' => array(
'rule' => 'notEmpty',
'message' => 'field Can not be empty!'
)
validRange 有
validRange' => array(
'rule' => array('comparison', '>', __('MAX_RANGE')),
is define in language file
'message' => 'field cant not be greater than maximum range'
)
你错过了里面的rule
'rule' => array('comparison', '>', __('MAX_RANGE')),
所以,最后你会有
<?php
$validation = array(
'field' => array(
'required' => array(
'rule' => 'notEmpty',
'message' => 'field Can not be empty!'
)),
'validRange' => array(
'rule' => array('comparison', '>', __('MAX_RANGE')), //here the syntax error should have gone :p
'message' => 'field cant not be greater than maximum range')
);
?>
答案 1 :(得分:-1)
您好试试此代码一次
$validation = array(
'field' => array(
'required' => array(
'rule' => 'notEmpty',
'message' => 'field Canenter code here not be empty!'
),
'validRange' => array(
'rule' => array('comparison', '>', __('MAX_RANGE')), //here is the syntax error. MAX_RANGE is a constant which is define in language file
'message' => 'field cant not be greater than maximum range'
)
)
)