protected function optgroupNest($data) { $html = new Html(); foreach ($data as $nest) { $nested = isset($nest['subs']) && !empty($nest['subs']) ? $this->optgroupNest($nest['subs']) : ''; $html->tag('optgroup'); isset($nest['class']) && $nest['class'] ? $html->class($nest['class']) : false; $html->label($nest['label']); foreach ($nest['options'] as $option) { $html->tag('option'); isset($option['class']) && $option['class'] ? $html->class($option['class']) : false; isset($option['value']) ? $html->value($option['value']) : false; isset($option['selected']) && $option['selected'] ? $html->selected() : false; $html->text($option['text']); $html->tag(); } $html->append($nested); $html->tag(); } return $html->give(); }