Hi guys,
In my application I am using the grocery crud to add a user . I am experiencing a problem on this. The set_rules and required fields are not working when I am clicking on the save button. Before that it is rendering fine and displaying the required filed labels with * symbol.
Here is my code
public function create_user(){ $crud = new grocery_CRUD(); $crud->set_table('user') ->set_subject('New User') ->columns('user_name','password','id_user_role','pubid') ->add_fields('user_name','password','id_user_role','pubid') ->edit_fields('user_name','password','id_user_role','pubid') ->set_relation('id_user_role','user_role','name') ->display_as('id_user_role','Role'); $state_code = $crud->getState(); if($state_code == 'edit') { $crud->required_fields('password','id_user_role'); $crud->set_rules('user_name','Username', 'trim|required|xss_clean'); }elseif($state_code == 'add'){ $crud->required_fields('user_name','password','id_user_role'); $crud->set_rules('user_name','Username', 'trim|required|xss_clean|is_unique[user.user_name]' ); } $output = $crud->render(); $data['gcrud'] = $output; $data['content'] = 'admin/create_user_view'; $this->load->view('template',$data); }
please help me to fix this.