Welcome Guest, Not a member yet? Register   Sign In
Form validation config & dynamic
#2

Is there a specific reason why you want to use the config file? Since you only have one validation rule in the config file, why not move it into the setConfigValidations() function?

Adding it before, or after, the switch would set that rule each time, and you can build the rest dynamically as you already doing.

Example
PHP Code:
private function setConfigValidations($page) {

   $this->form_validation->set_rules('submitData''selectTickets''trim|required|max_amount|min_amount');

   switch($page) {
       case 'tickets':
           $tickets $this->config->item('tb_tickets');
           
           foreach
(array_keys($tickets) as $ticket) {
                   $this->form_validation->set_rules($this->config->item('tb_tickets_name_form_prefix').$ticket'lang:'.$tickets[$ticket]['name'], 'trim|required|is_ticket|minimum|maximum');
           }
           
           break
;
       default:
           break;
   }

Reply


Messages In This Thread
Form validation config & dynamic - by BABYpanda - 03-17-2015, 12:03 PM
RE: Form validation config & dynamic - by silentium - 03-17-2015, 07:49 PM



Theme © iAndrew 2016 - Forum software by © MyBB