I wish to convert this arrayto an optgroup inthe following way while using the Codeigniter form_dropdown function.
<select>
<optgroup label="Thomas More Kempen">
<option value="22">D001</option>
<option value="23">D002</option>
</optgroup>
<optgroup label="Thomas More Geel">
<option value="2">G001</option>
<option value="8">A102</option>
</optgroup>
</select>
value is lokaalId
So far I could show the "Thomas More ..." in optgroup with objects ad chlildren, but so far no dice.
Solved: I changed the way I get my Data from the DB:
function getAllMetCampus() {
$this->load->model('campus_model');
$alleCampussen = $this->campus_model->getAll();
foreach ($alleCampussen as $campus) {
$lokalen = $this->getAllOnCampusId($campus->id);
foreach($lokalen as $key=>$value){
unset($lokalen[$key]);
$lokalen[$value->lokaalId] = $value->lokaalNr;
}
$result[$campus->naam] = $lokalen;
}
return $result;
}
Then I just echo form_dropdown($result);