codeigniter - [Solved] How to change {field} in ci form validation to Chinese
伊谢尔伦
伊谢尔伦 2017-05-16 16:43:27
0
3
457

Use a secondary encapsulated library, not ci's form_validate

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

reply all(3)
Ty80

CodeIgniter allows you to create multiple validation rules for a single form field, stacked together in order, and you can also preprocess the data of the form field at the same time. To set validation rules, you can use the set_rules() method:

$this->form_validation->set_rules();

The above method has three parameters:
1. Form domain name - it is the name you gave the form field.
2. The "humanized" name of the form field, which will be inserted into the error message. For example, if you have a form field called "user," you might give it a human-friendly name called "username."
3. Validation rules set for this form field.
(Optional) When this form field sets a custom error message, if this parameter is not set, the default one will be used.

刘奇
// 直接指定欄位的中文名稱
$this->form_validation->set_rules('Username', '用户名', 'required');

// 或是透過lang取得language裡指定的名稱
$this->form_validation->set_rules('Password', lang('Password'), 'required');
过去多啦不再A梦

The solution for now is to use a secondary encapsulation library. Let’s change it to Chinese. We will see how the library is written later and then change it to internationalization

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template