[eluser]David Johansson[/eluser]
Hmm, actually, it looks like you can set the rules first, and then run them all if we have the rules like ChristiaanT wrote:
[quote author="ChristiaanT" date="1247967763"]
Code:
$config = array(
'default' => array(
array(
'field' => 'person_name',
'label' => 'Name',
'rules' => 'required'
),
array(
'field' => 'person_email',
'label' => 'Email',
'rules' => 'required'
),
),
'blabla' => array(
array(
'field' => 'blabla_date',
'label' => 'Blabla date',
'rules' => 'required'
),
[/quote]
We could then do:
Code:
$data[formname] = $formname;
$this->form_validation->set_rules($config['default']);
$this->form_validation->set_rules($config[$formname]);
if ($this->form_validation->run() == FALSE){
$this->load->view('default/header', $data);
$this->load->view('form/form_persondata', $data);
$this->load->view('form/form_'.$formname, $data);
$this->load->view('form/form_footer', $data);
$this->load->view('default/footer');
}
If a rule exists for the same field in both the default and the form specific rule set only the later one will be user (this might be good for overriding).