18 $this->_id = is_array($id) ? implode(
'__',$id) : $id;
19 $this->_name =
'widget[' . str_replace(
'__',
'][',$this->_id) .
']';
21 $this->_widget = $widget;
26 return ($caption = $this->_widget->caption($this->_id)) ? $this->html->label($caption,[
'for' => $this->_id]) :
null;
34 $class = [
'widget',strtolower(\
Rsi\File::basename(get_called_class())),
$display];
35 if($this->_widget->required){
36 $class[] =
'required';
37 if(is_array($this->_widget->required)) $class[] =
'conditonal';
39 if(array_key_exists($this->_id,$this->_view->component(
'request')->errors)) $class[] =
'error';
40 return 'fred-' . implode(
' fred-',$class);
44 return $this->html->div(
45 $this->html->fieldset($content),
46 [
'title' => $this->_widget->hint($this->_id)],
53 return $this->html->input($value,
null,
'hidden',$this->_name);
59 $this->html->_div($raw ? $value : $this->_widget->format($value),
null,
'fred-value'),
65 return $this->html->input(
66 $raw ? $value : $this->_widget->format($value),
67 array_merge($this->
attribs(),$attribs ?: []),
75 $this->
renderInput($value,$raw,[$this->_inputDisabled =>
true]),
87 public function render($value =
null,$raw =
false){
89 foreach(array_reverse($this->displayNames) as
$display => $name)
90 if(($display <= $this->_widget->display) && method_exists($this,$method =
'render' . $name))
91 return call_user_func([$this,$method],$value,$raw);
96 return $this->_widget->defaultValue;
100 if(!$this->_displayNames){
101 foreach($this->_widget->constants(
'DISPLAY_') as $name => $value)
102 $this->_displayNames[$value] = ucfirst(strtolower($name));
103 ksort($this->_displayNames);
109 return $this->_view->component(
'html');