2011-12-24 124 views
1

在CodeIgniter中運行表單驗證時,是否可以更改matches調用的輸出?CodeIgniter表單驗證匹配標籤

我正在根據確認密碼框驗證密碼。

array(
    'field' => 'userPassword', 
    'label' => 'Password', 
    'rules' => 'trim|required|matches[userConfPassword]' 
) 

但在觸發錯誤它打印出:

The Password field does not match the userConfPassword field. 

的用戶不知道是userConfPassword手段,我想改變的東西更友好。閱讀文檔我找不到辦法做到這一點。

回答

5

好了,你可以覆蓋默認的消息:

$this->form_validation->set_message('matches', 'the two passwords do not match|'); 

或一些其他的消息一樣,:)。

我通常只將該消息用於「確認密碼」,但是,所以我根據需要設置了正常密碼字段,這就是所有,而確認我已將它匹配輸入的密碼,而不是其他地方或兩者)。但這只是我想的品味問題。

有關記錄,它寫在這paragraph of the manual

+0

完美!我從來沒有想到你可以覆蓋現有的信息。謝謝! – Seth 2011-12-24 17:08:28

0

此代碼的工作對我來說:

array(
    'field' => 'userPassword', 
    'label' => 'Password', 
    'rules' => 'trim|required|matches[userConfPassword]' 
), 
array(
    'field' => 'userConfPassword', 
    'label' => 'Confirm Password', 
    'rules' => 'trim|required' 
) 

當觸發錯誤它打印出:

密碼字段不確認密碼字段匹配。