38 require_once realpath(dirname(__FILE__)).
"/../field_renderers.inc";
55 if ($field && !$form->data->hasField($field))
57 $form->add($this, $field);
61 $form->override($field, $label, $this);
72 if (isset($this->thresholds))
74 krsort($this->thresholds, SORT_NUMERIC);
82 $id =
"{$this->parent->id}_{$field}";
84 $script = <<<ENDSCRIPT
85 <script type=
'text/javascript'>
87 window.addEvent(
'domready',
function()
89 var range = document.id(
'{$id}');
90 var display = document.id(
'{$id}_display');
94 range.addEvent(
'input',
function(elt)
96 if ({$id}_thresholds !=
null)
98 for(var score in {$id}_thresholds)
100 if (range.value == score)
102 display.set(
'html', ${id}_thresholds[score]);
108 display.set(
'text', range.value);
121 $this->_startField($field);
122 $value = $this->parent->data->get($field);
123 if (!$value) $value = $this->min;
125 echo
"<input type='range' id='{$this->parent->id}_{$field}' name='{$field}' min='{$this->min}' max='{$this->max}' value='{$value}' data-displayField='{$this->parent->id}_{$field}_display'/>";
127 if ($this->displayValue)
129 $threshold = ($this->thresholds) ? $this->thresholds[$value] :
"";
130 echo
"<span class='range_display' id='{$this->parent->id}_{$field}_display'>{$threshold}</span>";
133 $this->_endField($field);
FieldRenderer is the abstract base class for all FieldRenderers.
FieldRenderer($parent)
Constructor.
renderScript($field)
FieldRenderers can override this method to provide any Javascript that their control requires for an ...
__construct(&$form, $field, $min=0, $max=10, $editable=true)
renderField($field)
FieldRenderers must override this method to provide the HTML implementation of the control used to ed...
setThresholds($thresholds)