38 require_once realpath(dirname(__FILE__)).
"/../field_renderers.inc";
57 $this->onChange = $onchange;
60 if ($form->data->hasField($field))
62 $form->override($field, $label, $this);
66 $form->add($this, $field);
67 $form->alias($field, $label);
73 $label = isset($this->label) ? $this->label : $this->parent->prettifyFieldName($field);
86 if (!count($this->options))
return;
88 if(($this->horizontal || $this->tabular) && count($this->options) > 2)
92 $current = $this->parent->data->get($field);
100 if ($this->horizontal)
102 $width = 100 / count($this->options);
108 $tdStyle =
" style='width: {$width}%'";
115 echo
"<table class='radio_button_options'><tr><td{$tdStyle}>";
116 $separator = $this->horizontal ?
"</td><td>" :
"</td></tr><tr><td>";
118 else if ($this->horizontal)
120 $separator =
" ";
125 foreach($this->options as $value => $name)
127 $selected = ($current == $value) ?
" checked" :
"";
128 $onchange = (
$this->onChange) ?
"onclick='$this->onChange(this)'" :
"";
132 $out[] =
"<label class='radio' for='{$this->parent->id}_{$field}_{$value}'><input id='{$this->parent->id}_{$field}_{$value}' style='border: none' type='radio' name='$field' value='$value'$selected $onchange $disable/> $name</label>";
135 $radios = implode($separator, $out);
138 $radios .=
"</td></tr></table>";
152 if ($mode !=
"equal")
return;
154 $searchValue = $this->parent->params->get($field, $mode);
158 foreach($this->options as $value => $name)
160 $selected = ($searchValue == $value) ?
" checked" :
"";
161 echo
"<input style='border: none' type='radio' name='$field:$mode' value='$value'$selected>$name</option>";
162 echo ($this->horizontal) ?
" " :
"<br/>";
172 if (array_key_exists($this->parent->data->get($field), $this->options))
174 echo $this->options[$this->parent->data->get($field)];
178 echo
"Not specified";
FieldRenderer is the abstract base class for all FieldRenderers.
_startField($field, $styles="")
Internal method to generate the starting HTML for the field (including the label)
_endField($field)
Internal method to generate the closing HTML for the field.
_printLabel($field, $colspan=1, $styles="", $annotation="")
Internal method to generate the HTML for the field label.
FieldRenderer($parent)
Constructor.