php - multiple $this->form_validation->run() not work in codeigniter
one text
Solution:
I got solution above my question.
Remove office_address and residential_address from config->form_validation.php
You can Validate office and residential address in controller, See below Code:
public function addMemberForm(){
$validation_error = array();
if(!$this->form_validation->run('add_form')){
$validation_error[] = $this->form_validation->set_error_delimiters('<span style="color:red">','</span>');
}
elseif($this->input->post('mailing') == 'office'){
$this->form_validation->set_rules('office_address','Office Address','required');
if($this->form_validation->run() == false){
$validation_error[] = $this->form_validation->set_error_delimiters('<span style="color:red">','</span>');
}
}
elseif($this->input->post('mailing') == 'residential'){
$this->form_validation->set_rules('resi_address','Residential Address','required');
if($this->form_validation->run() == false){
$validation_error[] = $this->form_validation->set_error_delimiters('<span style="color:red">','</span>');
}
}
if(count($validation_error)){
$this->load->view('admin_panel/add-member');
}
else{
$this->session->set_flashdata('add_member_msg','<span class="alert alert-success">Member insert successfully</span>');
return redirect('admin/add_member');
}
}
Source