Framework  3.9
ColorFieldRenderer Class Reference

Field renderer for boolean data fields. More...

+ Inheritance diagram for ColorFieldRenderer:
+ Collaboration diagram for ColorFieldRenderer:

Public Member Functions

 __construct (&$parent, $field=null, $label=null)
 Create a new BooleanFieldRenderer. More...
 
 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...
 
 renderSearchField ($field, $mode="match")
 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...
 
 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

 $disable = false
 
 $onChange = null
 , alternative to readonly; field can be reenabled thru javascript More...
 
- 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 boolean data fields.

Renders as a checkbox.

Definition at line 43 of file color_field_renderer.inc.

Constructor & Destructor Documentation

◆ __construct()

ColorFieldRenderer::__construct ( $parent,
  $field = null,
  $label = null 
)

Create a new BooleanFieldRenderer.

Parameters
AutoForm$parentthe parent form

Definition at line 52 of file color_field_renderer.inc.

53  {
54  $this->FieldRenderer($parent);
55  if ($field && !$parent->data->hasField($field))
56  {
57  $parent->add($this, $field, $label);
58  }
59  }
FieldRenderer($parent)
Constructor.

Member Function Documentation

◆ renderField()

ColorFieldRenderer::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 83 of file color_field_renderer.inc.

84  {
85  $this->_startField($field);
86 
87  $val = $this->parent->data->get($field);
88 
89  $f = "{$this->parent->id}_{$field}";
90  $disable = ($this->disable) ? "disabled='disabled'" : "";
91 
92  echo "<input id='{$f}' class='color' type='text' size='7' value='{$val}' name='$field' {$disable} onkeyup='return {$f}_onChange(this);'>&nbsp;";
93  echo "<input id='{$f}_color' type='color' value='{$val}' name='{$field}' {$disable} onchange='return {$f}_color_onChange(this);'>";
94 
95  $this->_endField($field);
96  }
_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()

ColorFieldRenderer::renderReadOnly (   $field)

Definition at line 111 of file color_field_renderer.inc.

112  {
113  $this->_startField($field);
114 
115  $val = $this->parent->data->get($field);
116 
117  echo "<input id='{$this->parent->id}_{$field}' type='color' value='{$val}' name='$field' readonly='readonly'>";
118 
119  $this->_endField($field);
120  }

◆ renderScript()

ColorFieldRenderer::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 61 of file color_field_renderer.inc.

62  {
63  $f = "{$this->parent->id}_{$field}";
64  $onChange = ($this->onChange) ? " {$this->onChange}(elt);" : ";";
65 
66  echo <<<ENDSCRIPT
67  <script type='text/javascript'>
68  function {$f}_onChange(elt)
69  {
70  document.id('{$f}_color').value = elt.value;
71  return{$onChange}
72  }
73 
74  function {$f}_color_onChange(elt)
75  {
76  document.id('{$f}').value = elt.value;
77  return{$onChange}
78  }
79  </script>
80 ENDSCRIPT;
81  }
$onChange
, alternative to readonly; field can be reenabled thru javascript

◆ renderSearchField()

ColorFieldRenderer::renderSearchField (   $field,
  $mode = "match" 
)

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 color_field_renderer.inc.

99  {
100  $this->_startField($field);
101 
102  $val = $this->parent->data->get($field);
103 
104  $disable = ($this->disable) ? "disabled='disabled'" : "";
105  $onChange = ($this->onChange) ? " onchange='return {$this->onChange}(this);'" : "";
106  echo "<input id='{$this->parent->id}_{$field}' type='color' value='{$val}' name='$field:$mode' {$disable}{$onChange}>";
107 
108  $this->_endField($field);
109  }

Member Data Documentation

◆ $disable

ColorFieldRenderer::$disable = false

Definition at line 45 of file color_field_renderer.inc.

◆ $onChange

ColorFieldRenderer::$onChange = null

, alternative to readonly; field can be reenabled thru javascript

Name of Javascript function to be called when checkbox is toggled

Definition at line 46 of file color_field_renderer.inc.


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