38 require_once realpath(dirname(__FILE__)).
"/../field_renderers.inc";
62 if ($form->data->hasField($field))
64 $form->override($field, $label, $this);
68 $form->add($this, $field);
69 if ($label) $form->alias($field, $label);
76 if ($this->parent->readOnlyForm || $this->parent->isReadOnly($field))
return;
77 $id =
"{$this->parent->id}_{$field}";
79 <script type=
'text/javascript'>
80 function <?echo $id?>_update(sel)
82 value = sel.get(
'data-value');
84 $$(
'#<?echo $id?>_list li[data-value]').each(
function(elt)
86 var v = elt.get(
'data-value');
89 elt.addClass(
'selected');
93 elt.removeClass(
'selected');
97 var hidden = document.id(
'<?echo $id?>');
100 var f = document.id(
'<?echo $this->parent->id?>');
101 if (v != hidden.value && f && f.manager)
114 $value = $this->parent->data->get($field);
116 $id =
"{$this->parent->id}_{$field}";
118 echo
"<input type='hidden' id='{$id}' name='{$field}' value='{$value}'/>";
121 echo
"<ul id='{$id}_list' class='{$this->cssClass}'>";
122 foreach($this->options as $option => $description)
124 $selected = ($value == $option) ?
" class='selected'" :
"";
125 echo
"<li{$selected} data-value='{$option}' onclick='{$id}_update(this); return false;'>{$description}</li>\n";
131 echo
"<div id='{$id}_list' class='{$this->cssClass}'>";
133 foreach($this->options as $group =>
$options)
135 echo
"<{$this->groupTag}>{$group}</{$this->groupTag}>\n";
136 echo
"<ul class='{$this->cssClass}'>";
137 foreach(
$options as $option => $description)
139 $selected = ($value == $option) ?
" class='selected'" :
"";
140 echo
"<li{$selected} data-value='{$option}' onclick='{$id}_update(this); return false;'>{$description}</li>\n";
155 $value = $this->parent->data->get($field);
158 echo $this->options[$value];
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.
Displays a control that provides a highly styleable set of options from which the user can select a s...
$groupTag
The tag to use when displaying the groups.
$options
The array of options for the control to display, as value=>description pairs.
$grouped
True if the $options array is grouped by headings, false if not.
$cssClass
CSS class for the generated list of options. Use this to override the look and feel.
renderField($field)
FieldRenderers must override this method to provide the HTML implementation of the control used to ed...
OptionListFieldRenderer(&$form, $field, $label, $options, $grouped=false)
renderScript($field)
FieldRenderers can override this method to provide any Javascript that their control requires for an ...