38 require_once realpath(dirname(__FILE__)).
"/../field_renderers.inc";
62 $label = isset($this->label) ? $this->label : $this->parent->prettifyFieldName($field);
64 $this->parent->validator->add(
new DateValidator($field, $label));
84 $calendar =
"{$this->parent->id}_{$field}_calendar";
85 echo
"<script type='text/javascript'>\n";
86 echo
"var $calendar = new Calendar('$calendar', '', '{$this->parent->id}_{$field}');\n";
92 $obj = $this->parent->data;
95 $obj = $obj->findSubObject($field);
97 $date = $obj->format(
"{{$field}:m/d/Y}");
99 $onchange = (
$this->onChange) ?
"onchange='$this->onChange(this)'" :
"";
100 $oninput = (
$this->onInput) ?
"oninput='$this->onInput(this)'" :
"";
103 echo
"<input id='{$this->parent->id}_{$field}' type='text' name='$field' value='$date' $onchange $oninput style='width: auto' class='date' size='12'> <img src='{$this->parent->componentPath}/calendar/calendar.gif' alt='Popup Calendar' align='absmiddle' border='0' onclick='{$this->parent->id}_{$field}_calendar.toggle(this)'>\n";
111 if (!$this->_includedDateScript)
113 echo
"<script src='{$this->parent->componentPath}/calendar/sonjara_calendar.js' type='text/javascript'></script>\n";
114 echo
"<link href='{$this->parent->componentPath}/calendar/sonjara_calendar.css' type='text/css' rel='stylesheet'>\n";
115 $this->_includedDateScript =
true;
118 if ($mode ==
"range")
120 $calendar_from =
"{$field}_calendar_from";
121 $calendar_to =
"{$field}_calendar_to";
123 echo
"<script type='text/javascript'>\n";
124 echo
"var $calendar_from = new Calendar('$calendar_from', '{$this->parent->id}', '$field:from');\n";
125 echo
"var $calendar_to = new Calendar('$calendar_to', '{$this->parent->id}', '$field:to');\n";
130 $calendar =
"{$field}_calendar_{$mode}";
131 echo
"<script type='text/javascript'>\n";
132 echo
"var $calendar = new Calendar('$calendar', '{$this->parent->id}', '$field:$mode');\n";
141 if ($mode ==
"range")
143 $label = $this->parent->layout->getLabel($field, $this);
144 $toLabel = (preg_match(
"/Between/i", $label)) ?
"and" :
"to";
146 $date_from = $this->parent->params->get($field,
"from");
147 $date_to = $this->parent->params->get($field,
"to");
148 echo
"<input type='text' name='$field:from' value='$date_from' class='date' size='12'> <img src='{$this->parent->componentPath}/calendar/calendar.gif' alt='Popup Calendar' align='absmiddle' border='0' onclick='{$field}_calendar_from.toggle(this)'>";
149 echo
" <label for='date_to'>$toLabel</label> ";
150 echo
"<input type='text' name='$field:to' value='$date_to' class='date' size='12'> <img src='{$this->parent->componentPath}/calendar/calendar.gif' alt='Popup Calendar' align='absmiddle' border='0' onclick='{$field}_calendar_to.toggle(this)'>\n";
154 $date = $this->parent->params->get($field, $mode);
156 echo
"<input type='text' name='$field:$mode' value='$date' class='date' size='12'> <img src='{$this->parent->componentPath}/calendar/calendar.gif' alt='Popup Calendar' align='absmiddle' border='0' onclick='{$field}_calendar_{$mode}.toggle(this)'>\n";
166 echo $this->
format($this->parent->data->get($field));
173 $label = $this->parent->layout->getLabel($field, $this);
175 if($date_from && $date_to)
177 $toLabel = (preg_match(
"/Between/i", $label)) ?
"and" :
"to";
179 else if($date_from && !$date_to)
181 $this->label = preg_replace(
"/Between/i",
"From", $label);
185 $this->label = preg_replace(
"/(Between)|(From)/i",
"Up To", $label);
190 if ($this->parent->valueCSS) echo
" class='{$this->parent->valueCSS}'";
191 echo
">".$this->format($date_from).
" <label for='date_to'>$toLabel</label> " . $this->
format($date_to) .
"</td>\n";
Field renderer for date data fields.
renderSearchField($field, $mode)
FieldRenderers must override this method to provide the HTML implementation of the control displayed ...
renderSearchScript($field, $mode)
FieldRenderers can override this method to provide any Javascript that the control requires when bein...
$onInput
optional javascript callback for 'input' event on date text field
renderDateRangeReadOnly($field, $date_from, $date_to)
DateFieldRenderer(&$parent)
renderField($field)
FieldRenderers must override this method to provide the HTML implementation of the control used to ed...
renderScript($field)
FieldRenderers can override this method to provide any Javascript that their control requires for an ...
$onChange
optional javascript callback for 'change' event on date text field
$template
template for date display in readonly mode - default reaonly format is short style
addValidatorsToForm($field, $required=false)
This method is called by the AutoForm to add any default input validators that are required by the Fi...
static format($date, $template="")
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)
_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.