38 require_once realpath(dirname(__FILE__)).
"/../field_renderers.inc";
73 $this->international =
true;
78 $label = isset($this->label) ? $this->label : $this->parent->prettifyFieldName($field);
82 if (!$this->international)
84 $expr = $this->includePlus4 ?
"^\\d{5}(?:-\\d{4})?$" :
"^\\d{5}$";
86 $this->parent->regexp($field, $expr,
"Please supply a valid zip code.");
95 $size = $this->includePlus4 ? 10 : 5;
97 <script type=
'text/javascript'>
99 function <?echo $field ?>_keyup(event)
101 var ctrl = document.id(
'<? echo "{$this->parent->id}_$field" ?>');
102 var len = ctrl.value.length;
103 if (len >= <?echo $size?>)
105 ctrl.value = ctrl.value.substring(0, <?echo $size?>);
106 len = <?echo $size?>;
109 var count = ctrl.length;
113 count.innerHTML = len;
124 if (!$this->international)
126 $size = $this->includePlus4 ? 10 : 5;
127 $onkeyup =
" onkeyup='{$field}_keyup(event);'";
128 $onkeypress=
" onkeypress='return maskInput(event)'";
136 $onchange = (
$this->onChange) ?
"onchange='$this->onChange(this)'" :
"";
139 echo
"<input id='{$this->parent->id}_{$field}'
140 type='text' style='width: auto' name='$field' $onchange $autocomplete
141 value='".htmlspecialchars($this->parent->data->get($field), ENT_QUOTES,
'UTF-8').
"'
142 size='{$size}' $disable $onkeypress $onkeyup/>";
151 echo $this->parent->data->get($field);
160 $onkeyup =
" onkeyup='{$field}_keyup(event);'";
161 $onkeypress=
" onkeypress='return maskInput(event)'";
163 if ($mode ==
"range")
165 $from = htmlspecialchars($this->parent->params->get($field,
"from"), ENT_QUOTES,
'UTF-8');
166 $to = htmlspecialchars($this->parent->params->get($field,
"to"), ENT_QUOTES,
'UTF-8');
168 echo
"From <input type='text' id='$field' name='$field:from' value='{$from}' size='10'$onkeypress$onkeyup> to <input type='text' name='$field:to' value='{$to}' size='10'$onkeypress$onkeyup>";
172 $value = htmlspecialchars($this->parent->params->get($field, $mode), ENT_QUOTES,
'UTF-8');
173 echo
"<input type='text' id='$field' name='$field:$mode' value='{$value}' size='10'$onkeypress$onkeyup>";
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.
FieldRenderer($parent)
Constructor.
Field renderer for zipcode data fields.
setInternational($label="Postal Code")
renderSearchField($field, $mode="equal")
FieldRenderers must override this method to provide the HTML implementation of the control displayed ...
renderScript($field)
FieldRenderers can override this method to provide any Javascript that their control requires for an ...
addValidatorsToForm($field, $required=false)
This method is called by the AutoForm to add any default input validators that are required by the Fi...
renderField($field)
FieldRenderers must override this method to provide the HTML implementation of the control used to ed...
ZipCodeFieldRenderer(&$form)