38 require_once realpath(dirname(__FILE__)).
"/../field_renderers.inc";
62 $this->allowAdd = $allowAdd;
63 $this->allowNone = $allowNone;
64 $this->max_chars = $maxChars;
69 $form->override(
$field, $label, $this);
75 $obj =& $this->parent->data;
80 $related = $obj->getRelated($this->relatedClass,
$field);
81 $valueField = ($this->valueField !=
"") ? $this->valueField : $related->getPrimaryKey();
83 $img =
"<img src='".$related->get($imgField).
"'/>";
87 $img =
"Click to Select";
91 echo
"<input id='{$this->parent->id}_{$field}' type='hidden' name='$field' value='".$this->parent->data->get(
$field).
"'><button name='{$field}_button' class='{$this->parent->buttonCSS}' onclick='{$field}_toggle(); return false;'>$img</button>";
93 echo
"<div style='display: none; position: absolute' id='{$field}_options'>";
97 foreach($items as $item)
99 $valueField = ($this->valueField !=
"") ? $this->valueField : $item->getPrimaryKey();
102 echo
"<img style='cursor: pointer; float: left' src='{$item->$imgField}' onclick='{$field}_select(\"{$item->$valueField}\", \"{$item->$imgField}\"); return false;'/>";
113 <script type=
'text/javascript'>
115 function <?echo $field ?>_select(value, image)
117 var form = document.getElementById(
'<?echo $this->parent->id ?>');
118 var ctrl = form[
'<?echo $field ?>'];
119 var button = form[
'<?echo $field ?>_button'];
121 button.innerHTML =
"<img src='" + image +
"'/>";
123 <?
if ($this->onChange)
125 <?echo $this->onChange ?>(value, image);
131 function <?echo $field ?>_toggle()
133 var div = document.getElementById(
'<?echo $field ?>_options');
134 if (div.style.display ==
'none')
136 div.style.display =
'block';
140 div.style.display =
'none';
144 function <?echo $field ?>_hide()
146 var div = document.getElementById(
'<?echo $field ?>_options');
147 div.style.display =
'none';
183 if ($this->parent->valueCSS) echo
" class='{$this->parent->valueCSS}'";
204 $this->items =
query($this->relatedClass, $this->constraint);
205 if ($this->allowNone)
207 $this->items = array_merge(array(
new $this->relatedClass), $this->items);
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.
query($class)
Performs a query against the database, returning an array of DataItem objects of the specified class.