更新时间:2022-12-06 20:30:50
无法访问与您的字段名称相对应的错误消息"
我猜想当一个字段没有值且没有必需的规则时会显示上述错误:
I guess Above error is shown when a field has no value and no required rule:
尝试如下设置规则
$this->form_validation->set_rules('g-recaptcha-response', 'Captcha', 'required|callback_recaptcha');
或(对于CI的最新版本)
$this->form_validation->set_rules(
'g-recaptcha-response', /* Field */
'Captcha', /* Label */
array( /* Rules */
'required',
array($this->your_model, 'recaptcha')
)
);
OR
$this->form_validation->set_rules(
'g-recaptcha-response', /* Field */
'Captcha', /* Label */
array( /* Rules */
'required',
array('my_recaptcha', array($this->your_model, 'recaptcha'))
),
array( /* Error lists */
'my_recaptcha' => 'Invalid Recaptcha'
)
);
查看更多此处