CodeIgniter set_message无效

时间:2017-02-11 15:38:56

标签: php codeigniter

public function doAssignerSU() {

    $this->form_validation->set_rules('username', 'Username', 'required|alpha_numeric');
    $this->form_validation->set_rules('password', 'Password', 'required|alpha_numeric|min_length[4]');
    $this->form_validation->set_message('min_length','Minimum of 4 characters');

当我在视图中显示验证错误时,它仍会显示预设的“{field}必须至少为...”

我的错误是什么?提前致谢

1 个答案:

答案 0 :(得分:0)

像这样设置自定义消息..

$this->form_validation->set_rules('password', 'Password', 'required|alpha_numeric|min_length[4]',array('min_length'=>'Minimum of 4 characters'));

提示:您可以在设置规则时直接设置自定义消息。

有关详情,请参阅Codeigniter Form Validation