Home  >  Q&A  >  body text

codeigniter - [Solved] How to change {field} in ci form validation to Chinese

Use a secondary encapsulated library, not ci's form_validate

伊谢尔伦伊谢尔伦2713 days ago380

reply all(3)I'll reply

  • PHP中文网

    PHP中文网2017-05-16 16:45:27

    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.

    reply
    0
  • 怪我咯

    怪我咯2017-05-16 16:45:27

    // 直接指定欄位的中文名稱
    $this->form_validation->set_rules('Username', '用户名', 'required');
    
    // 或是透過lang取得language裡指定的名稱
    $this->form_validation->set_rules('Password', lang('Password'), 'required');

    reply
    0
  • 过去多啦不再A梦

    过去多啦不再A梦2017-05-16 16:45:27

    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

    reply
    0
  • Cancelreply