38 require_once realpath(dirname(__FILE__)).
"/../field_renderers.inc";
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 $fn =
"{$this->parent->id}_{$field}_update";
87 $containerId =
"{$this->parent->id}_{$field}_container";
88 $id =
"{$this->parent->id}_{$field}";
90 <script type=
'text/javascript'>
91 function <?echo $fn?>(element)
93 var container = document.id(
'<?echo $containerId?>');
95 element = document.id(element);
96 if (element.hasClass(
'selected'))
98 element.removeClass(
'selected');
102 element.addClass(
'selected');
107 container.getElements(
"a.selected").each(
function(elt)
109 values.push(elt.get(
'data-value'));
112 document.id(
'<?echo $id?>').value = values.join(
",");
121 if (!count($this->options))
return;
133 $current = $this->parent->data->get($field);
137 if ($this->regular && !$this->tabular)
139 $width = 100 / count($this->options);
140 $widthStyle =
" style='width: {$width}%'";
143 $containerId =
"{$this->parent->id}_{$field}_container";
145 $values = explode(
",", $current);
151 $width = 100 / count($this->options);
152 $tdStyle =
" style='width: {$width}%'";
159 echo
"<table id='{$containerId}' class='push_button_options'><tr><td{$tdStyle}>";
160 $separator =
"</td><td{$tdStyle}>";
161 $close =
"</td></tr></table>";
163 else if ($this->horizontal)
165 echo
"<div id='{$containerId}' class='push_button_options horizontal'>";
170 echo
"<div id='{$containerId}' class='push_button_options vertical'>";
174 $name = $mode ?
"$field:$mode" : $field;
176 echo
"<input type='hidden' id='{$this->parent->id}_{$field}' name='{$name}' value='$current'/>";
180 $max = count($this->options) - 1;
184 foreach($this->options as $value => $name)
186 $selected = (array_search($value, $values) !== FALSE) ?
" selected" :
"";
190 if ($count == 0) $position .=
" first";
191 if ($count == $max) $position .=
" last";
193 $handler = $readonly ?
"" :
"{$this->parent->id}_{$field}_update(this);{$onChange}";
196 $out[] =
"<a class='pushbutton{$position}{$selected}'{$widthStyle} href='#' data-value='{$value}' onclick='{$handler}return false' {$disable}/>{$name}</a>";
201 $buttons = implode($separator, $out);
209 if ($mode !=
"equal")
return;
211 $searchValue = $this->parent->params->get($field, $mode);
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.
FieldRenderer($parent)
Constructor.