CodeIgniter is_unique error message in language file

When using CodeIgniter, I like to set my error messages to application/language/english/form_validation_lang.php , which is great for every error message, but doesn't seem to work for the is_unique message, as it gives me a standard message "Email field must contain a unique value.

My code is:

$lang['is_unique'] = "The %s entered is already in use.";

+5
source share
1 answer

Create a file called form_validation_lang.php as shown below

  • application / language / english / form_validation_lang.php

Go to system / language / english / form_validation_lang.php find.

 $lang['form_validation_is_unique'] = 'The {field} field must contain a unique value.'; 

Copy the key above, then add to the application / language / english / form_validation_lang.php

 $lang['form_validation_is_unique'] = 'The {field} entered is already in use.'; 

Further

About Add Controller Form Validation

 $this->lang->load('form_validation', 'english'); 

how

 $this->lang->load('form_validation', 'english'); $this->form_validation->set_rules('username', 'Username', 'trim|required|is_unique[users.username]'); 

Note. If you use form_validation is_unique in other controllers and want to use this message, you will need to load this $this->lang->load('form_validation', 'english'); On to this controller if you do not decide to autoload it.

+1
source

All Articles