I’ve just started a little page using CodeIgniter and wanted to run CodeIgniter’s form validation magic tricks. For this, I’ve set some rules via config/form_validation.php:
$config = array(
array(
'field' => 'name',
'label' => 'Name',
'rules' => 'trim|required|max_length[64]'
)
);
But in addition to that, I wanted to set some specific rules inside the controller itself.
$this->form_validation->set_rules('name', 'Name', ' is_unique[table.name]');
My problem – the specific set_rules() seems to have reset all previously defined rules.
Is there a way to merge both set of rules? Or did I miss a method for that?
It is better to defined named array in the config file for each controller and use it as mentioned in the Codeginiter user guide.
Call it like $this->form_validation->run(‘signup’) with the name of the array.