I am trying to call $data['form_value'] from view in Codeigniter, but that array returns empty.
Here is my Controller:
$data['field'] = $this->cc->get_form_names($data['selid']);
foreach($data['field'] as $key=>$valuee) {
$data['form_value'] = $this->cc->get_form_value($valuee->select);
}
Now in the View:
foreach($field as $key=>$valuee) {
echo "<span\"> ".$valuee->disp_name." :</span>";
<select name=\"\">";
foreach($form_value as $v=>$vv) {
$value = $vv->select;
echo "<option value=\"".$vv->select."\" >".$vv->select."</option>";
}
echo"</select> ";
}
When I do var_dump($form_value) it return array(0) { }
How would I get that variable?
You are overwriting form_value in loop. Try below code in your controller.
$form_value = array();
foreach($data['field'] as $key=>$valuee) {
$form_value[] = $this->cc->get_form_value($valuee->select);
}
$data["form_value "] = $form_value ;