I am using Codeigniter 3.0.0 version
When trying access the value of a multi select drop down field named as subjecID[ ]
using $this->input->post()
method,it returning empty value. But When I am accessing the $_POST['subjectID']
I can see the value in the form of an array from the subjecID[ ]
field. Even In older version of Codeigniter I was able to get the data as an array from the post. So, what might be the issue. Please tell me if is there any configurations to change?
Below is my controller function.
protected function rules() {
$rules = array(
array(
'field' => 'name',
'label' => $this->lang->line("teacher_name"),
'rules' => 'trim|required|max_length[60]'
),
array(
'field' => 'subjectID',
'label' => $this->lang->line("select_subject"),
'rules' => 'required'
)
);
return $rules;
}
public function add() {
$this->data['subjects'] = $this->subject_create_m->get_subject();
if($_POST) {
$rules = $this->rules();
$this->form_validation->set_rules($rules);
if ($this->form_validation->run() == FALSE) {
$this->data['form_validation'] = validation_errors();
$this->data["subview"] = "teacher/add";
$this->load->view('_layout_main', $this->data);
} else {
$array = array();
$array['name'] = $this->input->post("name");
$array['specialization'] = serialize($this->input->post('subjectID[]'));
print_r($array);
}
} else {
$this->data["subview"] = "teacher/add";
$this->load->view('_layout_main', $this->data);
}
}
Below is the Output I am getting by printing the post using the following code
print_r($this->input->post(NULL, FALSE));
Array ( [name] => sfgfdsgfsd [subjectID] => )
Because of this issue every time the validation is failing.