Codeigniter overwriting default validation messages

Go To


I'm trying to overwrite the validation message defaults, which from what I understand should be easy enough by just placing a file called:


contents of this file are:


$lang['required']           = "required.";

I've done this, but it's just not overwriting the defaults, worse thing is that it WAS working, so not sure how I toggled this off.

I've also tried loading it directly from my custom libraries/MY_Form_validation.php class but still no luck there either.

<?php if (!defined('BASEPATH')) exit('No direct script access allowed.');

class MY_Form_validation extends CI_Form_validation {

    function __construct()

The file is loading because I can see echo's from there, but none of the messages are being overwritten. I'm also noticing that my custom validation functions are loading either. So it's loading the files but not applying them or something weird.

2012-04-03 22:17
by Rob


you file name should be form_validation_lang.php not MY_form_validation_lang.php check the codeiginter language class document

2012-04-04 08:36
by Zaher
Ya, that completely overwrites the defaults, does not extend them - Rob 2012-04-04 16:48
you said that "I'm trying to overwrite the validation message defaults" and this is how to do so , there is no way you can extend them you need to create your own lang file and then use the $this->form_validation->set_message('rule', 'Error Message'); to overwrite the rule in this controller not on the full app check 2012-04-05 05:44
i hope you rate it if you find it useful & if its the answer to your question . - Zaher 2012-04-07 05:22