FRED™  3.0
FRED™: Framework for Rapid and Easy Development
Select.php
Go to the documentation of this file.
1 <?php
2 
4 
5 class Select extends Options{
6 
7  protected function renderOptions($value,$attribs = null){
8  $group = null;
9  $options = $group_options = [];
10  foreach($this->options($value) as $key => $label){
11  if(count($label = explode($this->_widget->groupDelimiter,$label)) == 1) array_unshift($label,null);
12  if($label[0] != $group){
13  if($group_options) $options[$group] = $group_options;
14  $group = $label[0];
15  $group_options = [];
16  }
17  if($group) $group_options[$key] = $label[1];
18  else $options[$key] = $label[1];
19  }
20  if($group_options) $options[$group] = $group_options;
21  return $this->html->select(
22  $options,
23  array_merge($this->attribs(),$attribs ?: [],$this->_widget->multi ? ['multiple' => true] : []),
24  $value,
25  true,
26  $this->_name . ($this->_widget->multi ? '[]' : '')
27  );
28  }
29 
30 }
renderOptions($value, $attribs=null)
Definition: Select.php:7