Framework  3.9
RatingFieldRenderer Class Reference

Field renderer for numeric rating data fields. More...

+ Inheritance diagram for RatingFieldRenderer:
+ Collaboration diagram for RatingFieldRenderer:

Public Member Functions

 RatingFieldRenderer (&$form)
 
 renderScript ($field)
 FieldRenderers can override this method to provide any Javascript that their control requires for an edit form. More...
 
 renderField ($field)
 FieldRenderers must override this method to provide the HTML implementation of the control used to edit the field. More...
 
 renderReadOnly ($field)
 
 renderSearchField ($field, $mode="equal")
 FieldRenderers must override this method to provide the HTML implementation of the control displayed for the field in a search form. More...
 
- 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...
 
 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

 $ranks
 
 $minLabel
 
 $maxLabel
 
- 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 numeric rating data fields.

Renders as a series of radio buttons laid out horizontally, between minimum and maximum labels. Useful for surveys.

Definition at line 45 of file rating_field_renderer.inc.

Member Function Documentation

◆ RatingFieldRenderer()

RatingFieldRenderer::RatingFieldRenderer ( $form)

Definition at line 51 of file rating_field_renderer.inc.

52  {
53  $this->ranks = 5;
54  $this->minLabel = "(little)";
55  $this->maxLabel = "(very)";
56 
57  $this->FieldRenderer($form);
58  $this->colspan = 2;
59 
60  //$form->override($field, $label, $this);
61  }
FieldRenderer($parent)
Constructor.

◆ renderField()

RatingFieldRenderer::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 69 of file rating_field_renderer.inc.

70  {
71  $this->_startField($field);
72 
73  echo "{$this->minLabel}  ";
74  $current = $this->parent->data->get($field);
75 
76  for($i = 1; $i <= $this->ranks; ++$i)
77  {
78  $checked = ($current == $i) ? " checked='checked'" : "";
79  echo "<input type='radio' name='$field' value='$i'$checked>&nbsp;$i&nbsp;&nbsp;&nbsp;";
80  }
81 
82  echo "{$this->maxLabel}";
83 
84  $this->_endField($field);
85  }
_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.

◆ renderReadOnly()

RatingFieldRenderer::renderReadOnly (   $field)

Definition at line 88 of file rating_field_renderer.inc.

89  {
90  $this->_startField($field);
91 
92  echo $this->parent->data->get($field);
93 
94  $this->_endField($field);
95  }

◆ renderScript()

RatingFieldRenderer::renderScript (   $field)

FieldRenderers can override this method to provide any Javascript that their control requires for an edit form.

Parameters
string$fieldthe field name

Reimplemented from FieldRenderer.

Definition at line 63 of file rating_field_renderer.inc.

64  {
65  // No output
66  return "";
67  }

◆ renderSearchField()

RatingFieldRenderer::renderSearchField (   $field,
  $mode = "equal" 
)

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 97 of file rating_field_renderer.inc.

98  {
99  $this->renderField($field);
100  }
renderField($field)
FieldRenderers must override this method to provide the HTML implementation of the control used to ed...

Member Data Documentation

◆ $maxLabel

RatingFieldRenderer::$maxLabel

Definition at line 49 of file rating_field_renderer.inc.

◆ $minLabel

RatingFieldRenderer::$minLabel

Definition at line 48 of file rating_field_renderer.inc.

◆ $ranks

RatingFieldRenderer::$ranks

Definition at line 47 of file rating_field_renderer.inc.


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