38 require_once realpath(dirname(__FILE__)).
"/../field_renderers.inc";
62 $this->horizontal =
true;
67 $form->override(
$field, $label, $this);
72 $this->items =
query($this->relatedClass, $this->constraint);
80 $current = $this->parent->data->get(
$field);
82 foreach($this->items as $item)
84 $name = $this->
formatName($item, $this->nameField);
85 $valueField = ($this->valueField !=
"") ? $this->valueField : $item->getPrimaryKey();
88 echo
"<input type='radio' name='{$field}' value='{$item->$valueField}'";
89 if ($item->get(
$valueField) == $current) echo
" selected";
90 echo
"> $name\n";
92 echo ($this->horizontal) ?
" " :
"<br/>";
100 if ($mode !=
"equal")
return;
105 $valueField = ($this->valueField !=
"") ? $this->valueField : $item->primary_key;
108 $value = $this->parent->params->get(
$field, $mode);
109 $current = $this->parent->data->get(
$field);
111 foreach($this->items as $item)
113 $name = $this->
formatName($item, $this->nameField);
115 echo
"<input type='radio' name='{$field}:$mode' value='{$value}'";
116 if ($item->get(
$valueField) == $current) echo
" selected";
117 echo
"> $name\n";
119 echo ($this->horizontal) ?
" " :
"<br/>";
128 foreach($this->items as $item)
130 $valueField = $this->valueField ? $this->valueField : $item->getPrimaryKey();
134 $name = $this->
formatName($item, $this->nameField);
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)
formatName($item, $name)
Formats the given DataItem based on the supplied format string.
_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.