70 parent::__construct(
$name, $parameters, $form);
72 $this->list = (isset($parameters[
'list']) && is_array($parameters[
'list'])) ? $parameters[
'list'] :
false;
86 parent::setDefaults();
89 $this->defaults[
'defaultValue'] =
'';
90 $this->defaults[
'placeholder'] =
false;
91 $this->defaults[
'maxlength'] =
false;
92 $this->defaults[
'normalize'] =
true;
103 $type = strtolower($this->type);
106 $label = $this->htmlLabel();
112 return "<p {$wrapperAttributes}>" .
114 "<span class=\"depage-label\">{$label}{$marker}</span>" .
115 "<input name=\"{$this->name}\" type=\"{$type}\"{$inputAttributes} value=\"{$value}\">" .
131 if ($this->list && is_array($this->list)) {
135 $htmlList =
"<datalist id=\"{$formName}-{$this->name}-list\">";
137 foreach ($options as $index => $option) {
139 if (is_int($index)) {
140 $htmlList .=
"<option value=\"{$option}\">";
142 $htmlList .=
"<option value=\"{$index}\" label=\"{$option}\">";
146 $htmlList .=
"</datalist>";
161 $attributes = parent::htmlInputAttributes();
163 if ($this->maxlength) $attributes .=
" maxlength=\"{$this->maxlength}\"";
164 if ($this->placeholder) $attributes .=
" placeholder=\"{$this->placeholder}\"";
165 if ($this->list) $attributes .=
" list=\"{$this->formName}-{$this->name}-list\"";
167 $attributes .= $this->validator->getPatternAttribute();
180 $this->value = preg_replace(
'/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/u',
'', (
string) $this->value);
182 if ($this->normalize && class_exists(
"\\Normalizer")) {
183 $this->value = \Normalizer::normalize($this->value);
htmlEscape($options=array())
Escapes HTML in strings and arrays of strings.
$value
Input elements's value.
$formName
Name of the parent HTML form.
$label
Input element - HTML label.
$errorMessage
Message that gets displayed in case of invalid input.
htmlHelpMessage()
Returns HTML-rendered helpMessage.
htmlWrapperAttributes()
Returns string of HTML attributes for element wrapper paragraph.
htmlMarker()
Returns elements' required-indicator.
$type
Input element type - HTML input type attribute.
$helpMessage
Extra help message.
htmlValue()
Returns HTML-rendered element value.
$marker
Input element - HTML marker text that marks required fields.
htmlErrorMessage()
Returns HTML-rendered error message.
htmlInputAttributes()
renders text element specific HTML attributes
$normalize
wether to normalize unicode strings or not
__construct($name, $parameters, $form)
text class constructor
typeCastValue()
Converts value to element specific type.
__toString()
Renders element to HTML.
$placeholder
HTML placeholder attribute.
setDefaults()
collects initial values across subclasses
htmlList($options=null)
Renders HTML datalist.
$maxlength
HTML maxlength attribute.
Abstract element classes.
Classes for HTML input-elements.