38 require_once realpath(dirname(__FILE__)).
"/../field_renderers.inc";
58 if ($form->data->hasField($field))
60 $form->override($field, $label, $this);
64 $form->add($this, $field);
65 if ($label) $form->alias($field, $label);
72 if ($this->parent->readOnlyForm || $this->parent->isReadOnly($field))
return;
73 $id =
"{$this->parent->id}_{$field}";
75 <script type=
'text/javascript'>
76 function <?echo $id?>_update(sel)
78 if (sel.hasClass(
"selected"))
80 sel.removeClass(
"selected");
84 sel.addClass(
"selected");
89 $$(
'#<?echo $id?>_list > li').each(
function(elt)
91 if (elt.hasClass(
'selected'))
93 var v = elt.get(
'data-value');
98 var hidden = document.id(
'<?echo $id?>');
100 hidden.value = values.join(
",");
101 var f = document.id(
'<?echo $this->parent->id?>');
102 if (v != hidden.value && f && f.manager)
115 $value = $this->parent->data->get($field);
117 $values = explode(
",", $value);
118 $values = array_combine($values, $values);
120 $id =
"{$this->parent->id}_{$field}";
122 echo
"<input type='hidden' id='{$id}' name='{$field}' value='{$value}'/>";
123 echo
"<ul id='{$id}_list' class='{$this->cssClass}'>";
124 foreach($this->options as $option => $description)
126 $selected = ($values[$option] == $option) ?
" class='selected'" :
"";
127 echo
"<li{$selected} data-value='{$option}' onclick='{$id}_update(this); return false;'>{$description}</li>\n";
138 $value = $this->parent->data->get($field);
139 $values = explode(
",", $value);
141 foreach($values as $v)
143 $text[] = $this->options[$v];
146 echo implode($this->separator, $text);
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 n...
OptionCheckListFieldRenderer(&$form, $field, $label, $options)
renderScript($field)
FieldRenderers can override this method to provide any Javascript that their control requires for an ...
renderField($field)
FieldRenderers must override this method to provide the HTML implementation of the control used to ed...