Form validation ignores language when changed during run-time Form validation ignores language when changed during run-time codeigniter codeigniter

Form validation ignores language when changed during run-time


The problem was that I was doing AJAX requests that didn't took into account the URI segment that contained the language abbreviation, because the URI for AJAX requests didn't needed the language segment in the first place, so I totally forgot about it.

Therefore I used the session cookie to store the language. Changing the multilang constructor to:

class multilang extends CI_Model {    public function __construct() {        parent::__construct();        # store lang between session        $data = $this->session->all_userdata();        if (isset($data['language'])) {            $lang = $data['language'];            # if lang was changed between sessions            if ($this->uri->segment(1) == 'fr'){                $lang = 'french';            } else if ($this->uri->segment(1) == 'en'){                $lang = 'english';            }            # if lang was changed using one of the lang abbreviations            # overule session setting            if ($this->uri->segment(1) == 'en') {                $lang = 'english';            } else if ($this->uri->segment(1) == 'fr') {                $lang = 'french';            }            $this->config->set_item('language', $lang);            $this->session->set_userdata('language', $lang);           } else {            if ($this->uri->segment(1) == 'en') {                $this->config->set_item('language', 'english');                $this->session->set_userdata('language', 'english');            } else if ($this->uri->segment(1) == 'fr') {                $this->config->set_item('language', 'french');                $this->session->set_userdata('language', 'french');            }        }    }}

Note: The change to the form_validation constructor wasn't required.

Answer provided for future reference, and to remind people of little things we miss. It was so obvious right! Well this might help the next one who forgets.

Closing question.