Framework  3.9
RelatedItemRadioButtonFieldRenderer Class Reference

Field renderer for related item data fields. More...

+ Inheritance diagram for RelatedItemRadioButtonFieldRenderer:
+ Collaboration diagram for RelatedItemRadioButtonFieldRenderer:

Public Member Functions

 RelatedItemRadioButtonFieldRenderer (&$form, $field, $label, $relatedClass, $constraint, $nameField, $valueField="")
 
 getRelatedItems ()
 
 renderField ($field)
 FieldRenderers must override this method to provide the HTML implementation of the control used to edit the field. More...
 
 renderSearchField ($field, $mode)
 FieldRenderers must override this method to provide the HTML implementation of the control displayed for the field in a search form. More...
 
 renderReadOnly ($field)
 
- Public Member Functions inherited from FieldRenderer
 FieldRenderer ($parent)
 Constructor. More...
 
 _printLabel ($field, $colspan=1, $styles="", $annotation="")
 Internal method to generate the HTML for the field label. More...
 
 _getLabel ($field, $addSuffix=true)
 
 _startField ($field, $styles="")
 Internal method to generate the starting HTML for the field (including the label) More...
 
 _endField ($field)
 Internal method to generate the closing HTML for the field. More...
 
 addValidatorsToForm ($field, $required=false)
 This method is called by the AutoForm to add any default input validators that are required by the FieldRenderer. More...
 
 addSearchValidatorsToForm ($field, $mode, $required=false)
 For SearchForm, the validator field needs to match the name tag in the form which is in the format field:mode. More...
 
 formatName ($item, $name)
 Formats the given DataItem based on the supplied format string. More...
 
 renderScript ($field)
 FieldRenderers can override this method to provide any Javascript that their control requires for an edit form. More...
 
 renderSearchScript ($field, $mode)
 FieldRenderers can override this method to provide any Javascript that the control requires when being used in a search form. More...
 
 renderOnSubmitHandler ($field)
 FieldRenderers can override this method to provide any Javascript that must be executed when the form is submitted on the client. More...
 
 preProcess ($field="")
 FieldRenderers can override this method to provide behavior that occurs prior to the saving of the parent form's target object to the database. More...
 
 postProcess ($field="")
 FieldRenderers can override this method to provide behavior that occurs after the parent form's target object has been saved to the database. More...
 

Public Attributes

 $items
 
 $default
 
 $field
 
 $nameField
 
 $valueField
 
 $relatedClass
 
 $constraint
 
 $horizontal
 
- Public Attributes inherited from FieldRenderer
 $parent = null
 
 $labelSuffix = ""
 
 $colspan = 1
 
 $annotateBefore = false
 
 $annotateNextLine = true
 
 $hideLabel = false
 
 $onPreProcess = null
 callback hook for processing prior to saving the form's data object - individual renderers may override with custom processing More...
 
 $onPostProcess = null
 callback hook for processing after saving the form's data object - individual renderers may override with custom processing More...
 

Detailed Description

Field renderer for related item data fields.

Renders as a list of radio button options.

Definition at line 44 of file related_item_radio_button_field_renderer.inc.

Member Function Documentation

◆ getRelatedItems()

RelatedItemRadioButtonFieldRenderer::getRelatedItems ( )

Definition at line 70 of file related_item_radio_button_field_renderer.inc.

71  {
72  $this->items = query($this->relatedClass, $this->constraint);
73  return $this->items;
74  }
query($class)
Performs a query against the database, returning an array of DataItem objects of the specified class.
Definition: query.inc:373

◆ RelatedItemRadioButtonFieldRenderer()

RelatedItemRadioButtonFieldRenderer::RelatedItemRadioButtonFieldRenderer ( $form,
  $field,
  $label,
  $relatedClass,
  $constraint,
  $nameField,
  $valueField = "" 
)

◆ renderField()

RelatedItemRadioButtonFieldRenderer::renderField (   $field)

FieldRenderers must override this method to provide the HTML implementation of the control used to edit the field.

Parameters
string$fieldthe field name

Reimplemented from FieldRenderer.

Definition at line 76 of file related_item_radio_button_field_renderer.inc.

77  {
78  $this->_startField($field);
79 
80  $current = $this->parent->data->get($field);
81 
82  foreach($this->items as $item)
83  {
84  $name = $this->formatName($item, $this->nameField);
85  $valueField = ($this->valueField != "") ? $this->valueField : $item->getPrimaryKey();
86  //trace("valueField: $valueField", 3);
87 
88  echo "<input type='radio' name='{$field}' value='{$item->$valueField}'";
89  if ($item->get($valueField) == $current) echo " selected";
90  echo ">&nbsp;$name\n";
91 
92  echo ($this->horizontal) ? "&nbsp;&nbsp;&nbsp;" : "<br/>";
93  }
94 
95  $this->_endField($field);
96  }
_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.

◆ renderReadOnly()

RelatedItemRadioButtonFieldRenderer::renderReadOnly (   $field)

Definition at line 124 of file related_item_radio_button_field_renderer.inc.

125  {
126  $this->_startField($field);
127 
128  foreach($this->items as $item)
129  {
130  $valueField = $this->valueField ? $this->valueField : $item->getPrimaryKey();
131 
132  if ($this->parent->data->get($field) == $item->get($valueField))
133  {
134  $name = $this->formatName($item, $this->nameField);
135  echo $name;
136  break;
137  }
138  }
139  $this->_endField($field);
140  }

◆ renderSearchField()

RelatedItemRadioButtonFieldRenderer::renderSearchField (   $field,
  $mode 
)

FieldRenderers must override this method to provide the HTML implementation of the control displayed for the field in a search form.

Parameters
string$fieldthe field name

Reimplemented from FieldRenderer.

Definition at line 98 of file related_item_radio_button_field_renderer.inc.

99  {
100  if ($mode != "equal") return;
101 
102  echo "<tr>\n";
103  $this->_printLabel($field);
104  echo "<td>";
105  $valueField = ($this->valueField != "") ? $this->valueField : $item->primary_key;
106  //trace("valueField: $valueField", 3);
107 
108  $value = $this->parent->params->get($field, $mode);
109  $current = $this->parent->data->get($field);
110 
111  foreach($this->items as $item)
112  {
113  $name = $this->formatName($item, $this->nameField);
114 
115  echo "<input type='radio' name='{$field}:$mode' value='{$value}'";
116  if ($item->get($valueField) == $current) echo " selected";
117  echo ">&nbsp;$name\n";
118 
119  echo ($this->horizontal) ? "&nbsp;&nbsp;&nbsp;" : "<br/>";
120  }
121  echo "</select>";
122  }
_printLabel($field, $colspan=1, $styles="", $annotation="")
Internal method to generate the HTML for the field label.

Member Data Documentation

◆ $constraint

RelatedItemRadioButtonFieldRenderer::$constraint

Definition at line 52 of file related_item_radio_button_field_renderer.inc.

◆ $default

RelatedItemRadioButtonFieldRenderer::$default

Definition at line 47 of file related_item_radio_button_field_renderer.inc.

◆ $field

RelatedItemRadioButtonFieldRenderer::$field

Definition at line 48 of file related_item_radio_button_field_renderer.inc.

◆ $horizontal

RelatedItemRadioButtonFieldRenderer::$horizontal

Definition at line 53 of file related_item_radio_button_field_renderer.inc.

◆ $items

RelatedItemRadioButtonFieldRenderer::$items

Definition at line 46 of file related_item_radio_button_field_renderer.inc.

◆ $nameField

RelatedItemRadioButtonFieldRenderer::$nameField

Definition at line 49 of file related_item_radio_button_field_renderer.inc.

◆ $relatedClass

RelatedItemRadioButtonFieldRenderer::$relatedClass

Definition at line 51 of file related_item_radio_button_field_renderer.inc.

◆ $valueField

RelatedItemRadioButtonFieldRenderer::$valueField

Definition at line 50 of file related_item_radio_button_field_renderer.inc.


The documentation for this class was generated from the following file: