Framework  3.9
TimeFieldRenderer Class Reference

Field renderer for time data fields. More...

+ Inheritance diagram for TimeFieldRenderer:
+ Collaboration diagram for TimeFieldRenderer:

Public Member Functions

 TimeFieldRenderer (&$parent)
 
 writeScript ($field)
 
 renderField ($field)
 FieldRenderers must override this method to provide the HTML implementation of the control used to edit 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...
 
 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)
 
 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...
 
- 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...
 
 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...
 
 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...
 

Additional Inherited Members

- 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 time data fields.

Definition at line 43 of file time_field_renderer.inc.

Member Function Documentation

◆ addValidatorsToForm()

TimeFieldRenderer::addValidatorsToForm (   $field,
  $required = false 
)

This method is called by the AutoForm to add any default input validators that are required by the FieldRenderer.

Fields that need custom validation or a custom required validator should override this function.

Parameters
string$fieldthe field name
boolean$required- whether the field is required

Reimplemented from FieldRenderer.

Definition at line 78 of file time_field_renderer.inc.

79  {
80  $prettyName = $this->parent->prettifyFieldName($field);
81 
82  $this->parent->validator->add(new TimeValidator($field, $label));
83 
84  if($required)
85  {
86  $this->parent->validator->add(new RequiredTimeValidator($field, $label));
87  }
88  }
RequiredTimeValidator.
Definition: validation.inc:702
TimeValidator.
Definition: validation.inc:658

◆ preProcess()

TimeFieldRenderer::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.

For example, the FileUploadFieldRenderer overrides this method to process the uploading of the file and then store the location in the associated field in the target object.

Parameters
string$fieldthe field name

Reimplemented from FieldRenderer.

Definition at line 116 of file time_field_renderer.inc.

117  {
118  $hh = checkNumeric($_POST["{$field}_hh"]);
119  $mm = checkNumeric($_POST["{$field}_mm"]);
120  $aa = $_POST["{$field}_aa"];
121  if ($aa != "AM" && $aa != "PM") die("Invalid meridiem");
122 
123  // JDG - allow time fields to be empty
124  if(!$hh)
125  {
126  $this->parent->data->set($field, $this->parent->data->reformatToSQLDate("00:00"));
127  return;
128  }
129 
130  if ($aa == "PM" && $hh != "12") $hh += 12;
131  if ($aa == "AM" && $hh == "12") $hh = "00";
132  $this->parent->data->set($field, "$hh:$mm");
133  }
checkNumeric($p)
Security helper function.
Definition: functions.inc:630

◆ renderField()

TimeFieldRenderer::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 55 of file time_field_renderer.inc.

56  {
57  $value = $this->parent->data->get($field);
58 
59  // JDG show as empty if value stored is 00
60  if ($value AND $value != '00:00:00')
61  {
62  $text = date("h/i/A", strtotime($value));
63  list($hh, $mm, $aa) = explode("/", $text);
64  }
65 
66  $this->_startField($field);
67 
68  echo "<input type='text' value='$hh' name='{$field}_hh' size='2' maxlength='2' onkeydown='return maskInput(event);'>&nbsp;:&nbsp;<input type='text' value='$mm' name='{$field}_mm' size='2' maxlength='2' onkeydown='return maskInput(event);'>";
69  echo "&nbsp;<select name='{$field}_aa'><option";
70  if ($aa == 'AM') echo " selected";
71  echo ">AM</option><option";
72  if ($aa == 'PM') echo " selected";
73  echo ">PM</option></select>";
74 
75  $this->_endField($field);
76  }
_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()

TimeFieldRenderer::renderReadOnly (   $field)

Definition at line 105 of file time_field_renderer.inc.

106  {
107  $this->_startField($field);
108 
109  //echo date('h:i A', strttotime($this->parent->data->get($field)));
110 
111  echo $this->parent->data->format("{{$field}:h:i A}");
112 
113  $this->_endField($field);
114  }

◆ renderSearchField()

TimeFieldRenderer::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 90 of file time_field_renderer.inc.

91  {
92  echo "<tr>\n";
93  echo "<td colspan='2'";
94  if ($this->parent->labelCSS) echo " class='{$this->parent->labelCSS}'";
95  echo "><input type='checkbox' value='1' name='$field:$mode'";
96  if ($this->parent->data->get($field))
97  {
98  echo " checked";
99  }
100  echo ">&nbsp;";
101  echo $this->parent->prettifyFieldName($field);
102  echo "</td>\n</tr>\n";
103  }

◆ TimeFieldRenderer()

TimeFieldRenderer::TimeFieldRenderer ( $parent)

Definition at line 45 of file time_field_renderer.inc.

46  {
47  $this->FieldRenderer($parent);
48  }
FieldRenderer($parent)
Constructor.

◆ writeScript()

TimeFieldRenderer::writeScript (   $field)

Definition at line 50 of file time_field_renderer.inc.

51  {
52  //TODO: Script to mask for correct input
53  }

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