38 require_once realpath(dirname(__FILE__)).
"/../field_renderers.inc";
87 <script type=
'text/javascript'>
89 function <?echo $field ?>_keyup(event)
91 var form = document.id(
'<?echo $this->parent->id ?>');
93 var ctrl = form[
'<?echo $field ?>'];
94 var len = ctrl.value.length;
95 if (len >= <?echo $this->limit?>)
97 ctrl.value = ctrl.value.substring(0, <?echo $this->limit ?>);
98 len = <?echo $this->limit ?>;
101 var count = document.getElementById(
'<?echo $field ?>_length');
105 count.innerHTML = len;
119 $onkeypress =
" onkeyup='{$field}_keyup(event);'";
122 if (!$onkeypress && $this->onKeyPress)
124 $onkeypress =
" onkeyup='return {$this->onKeyPress}(this);'";
128 $onchange = (
$this->onChange) ?
"onchange='$this->onChange(this)'" :
"";
131 $style = (
$this->width) ?
" style='width: {$this->width}'" :
"";
133 $value = (!
$this->password) ? htmlspecialchars($this->parent->data->get($field), ENT_QUOTES,
'UTF-8') :
"";
135 $keyPress = $this->numeric ?
"onkeypress='return maskInput(event, false);'" :
"";
139 echo
"<input id='{$this->parent->id}_{$field}' type='$inputType' name='$field' $placeholder $keyPress $onchange $autocomplete $class $style value='$value' size='{$this->size}' $disable $onkeypress/>";
155 echo
"<input id='{$this->parent->id}_{$confirm}' type='$inputType' name='$confirm' $autocomplete value='".htmlspecialchars($this->parent->data->get($field), ENT_QUOTES,
'UTF-8').
"' size='{$this->size}' $disable/>";
165 if (!$this->parent->readOnlyForm)
167 echo
"<input id='{$this->parent->id}_{$field}' type='hidden' name='$field' value='".htmlspecialchars($this->parent->data->get($field), ENT_QUOTES,
'UTF-8').
"'/>";
170 echo $this->
format($field);
177 if ($mode ==
"range")
179 $from = htmlspecialchars($this->parent->params->get($field,
"from"), ENT_QUOTES,
'UTF-8');
180 $to = htmlspecialchars($this->parent->params->get($field,
"to"), ENT_QUOTES,
'UTF-8');
184 echo
"<td>From <input type='text' id='$field' name='$field:from' value='{$from}' size='25'> to <input type='text' name='$field:to' value='{$to}' size='25'></td>\n";
189 $value = htmlspecialchars($this->parent->params->get($field, $mode), ENT_QUOTES,
'UTF-8');
192 echo
"<input type='text' id='$field' name='$field:$mode' {$placeholder} value='{$value}' size='{$this->size}' >\n";
200 $label = isset($this->label) ? $this->label : $this->parent->prettifyFieldName($field);
202 $confirmLabel =
"Confirm $label";
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.
Tests whether two fields contain the same value.
Field renderer for string data fields.
$onKeyPress
Optional key press javascript callback. Note that if $limit is set, it will override this.
$disable
alternative to readonly; field can be reenabled thru javascript
$template
StringTypeRenderer template for readonly format (e.g., "prettify")
$confirm
Render a second field for the user to confirm their entry (for email addresses, etc)
renderField($field, $readonly=false)
$limit
optional - restricts users from entering character count over limit
$autocomplete
default is true. Set to false to disable autocompletion
$numeric
Restrict to numeric input.
$placeholder
Placeholder text to display when field is empty.
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 ...
$width
Optionally specify a CSS width for the field.
$password
Render the field as a password field (masked characters)
$CSSclass
Optionally specify a CSS class for the field.
StringFieldRenderer(&$parent)
addValidatorsToForm($field, $required=false)
This method is called by the AutoForm to add any default input validators that are required by the Fi...
$onChange
optional (javascript) callback on data input change
static format($value, $template="")