5 class Options extends \Rsi\Fred\Controller\View\Html\Widget{
8 if(($popular = $this->_widget->popular) && $value)
9 foreach((array)$value as $key)
if(!array_key_exists($key,$popular)){
13 return \Rsi\Record::merge(
14 $this->_widget->placeholder ? [null => $this->_view->component(
'trans')->str($this->_widget->placeholder)] : [],
15 $popular ?: $this->_widget->options
19 protected function renderGroup($value,$attribs,$options,$group = null){
20 if(!$options)
return null;
21 $options = $this->html->input($value,$attribs,$this->_widget->multi ?
'checkbox' :
'radio',$this->_name,$options);
23 ? $this->html->div($this->html->label($group,[
'class' =>
'fred-group']) . $options,null,
'fred-group')
28 $this->html->escape = $this->_widget->escape;
29 $attribs = array_merge($this->
attribs(),$attribs ?: []);
30 $content = $group = null;
32 foreach($this->
options($value) as $key => $label){
33 if(count($label = explode($this->_widget->groupDelimiter,$label)) == 1) array_unshift($label,null);
34 if($label[0] != $group){
35 $content .= $this->
renderGroup($value,$attribs,$options,$group);
39 $options[$key] = $label[1];
41 return $content . $this->
renderGroup($value,$attribs,$options,$group);
45 $content = $this->
renderHidden($this->_widget->multi ? json_encode($value) : $value,$raw);
46 foreach(\
Rsi\Record::select($this->_widget->options,$this->_widget->multi ? $value : [$value]) as $descr)
47 $content .= $this->html->_div($descr,null,
'value');
48 return $this->
container($content,
'minimal');