17 $this->_id = is_array($id) ? implode(
'__',$id) : $id;
18 $this->_name =
'widget[' . str_replace(
'__',
'][',$this->_id) .
']';
20 $this->_widget = $widget;
25 return ($caption = $this->_widget->caption($this->_id)) ? $this->html->label($caption,[
'for' => $this->_id]) : null;
33 $class = [
'widget',strtolower(\
Rsi\File::basename(get_called_class())),
$display];
34 if($this->_widget->required){
35 $class[] =
'required';
36 if(is_array($this->_widget->required)) $class[] =
'conditonal';
38 if(array_key_exists($this->_id,$this->_view->component(
'request')->errors)) $class[] =
'error';
39 return 'fred-' . implode(
' fred-',$class);
43 return $this->html->div(
44 $this->html->fieldset($content),
45 [
'title' => $this->_widget->hint($this->_id)],
52 return $this->html->input($value,null,
'hidden',$this->_name);
58 $this->html->_div($raw ? $value : $this->_widget->format($value),null,
'fred-value'),
64 return $this->html->input(
65 $raw ? $value : $this->_widget->format($value),
66 array_merge($this->
attribs(),$attribs ?: []),
74 $this->
renderInput($value,$raw,[$this->_inputType ==
'text' ?
'readonly' :
'disabled' =>
true]),
86 public function render($value = null,$raw =
false){
88 foreach(array_reverse($this->displayNames) as
$display => $name)
89 if(($display <= $this->_widget->display) && method_exists($this,$method =
'render' . $name))
90 return call_user_func([$this,$method],$value,$raw);
95 return $this->_widget->defaultValue;
99 if(!$this->_displayNames){
100 foreach($this->_widget->constants(
'DISPLAY_') as $name => $value)
101 $this->_displayNames[$value] = ucfirst(strtolower($name));
102 ksort($this->_displayNames);
108 return $this->_view->component(
'html');
$display
Default display mode for widgets.
Framework for Rapid and Easy Development.