Run multiple form validation from config file

#12
[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).


Messages In This Thread
Run multiple form validation from config file - by El Forum - 07-18-2009, 02:42 PM
Run multiple form validation from config file - by El Forum - 07-19-2009, 12:39 AM
Run multiple form validation from config file - by El Forum - 07-19-2009, 12:41 AM
Run multiple form validation from config file - by El Forum - 07-19-2009, 05:14 AM
Run multiple form validation from config file - by El Forum - 07-20-2009, 02:58 AM
Run multiple form validation from config file - by El Forum - 07-20-2009, 03:28 AM
Run multiple form validation from config file - by El Forum - 07-20-2009, 03:35 AM
Run multiple form validation from config file - by El Forum - 07-20-2009, 03:37 AM
Run multiple form validation from config file - by El Forum - 07-20-2009, 03:49 AM
Run multiple form validation from config file - by El Forum - 07-27-2009, 05:22 PM
Run multiple form validation from config file - by El Forum - 07-27-2009, 10:13 PM
Run multiple form validation from config file - by El Forum - 07-27-2009, 10:28 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.