37 if ( isset(
$params[
'autocomplete'] ) && is_bool(
$params[
'autocomplete'] ) ) {
43 if ( isset(
$params[
'placeholder-message'] ) ) {
44 $this->mPlaceholder = $this->
getMessage(
$params[
'placeholder-message'] )->text();
45 } elseif ( isset(
$params[
'placeholder'] ) ) {
46 $this->mPlaceholder =
$params[
'placeholder'];
55 return $this->mParams[
'size'] ?? 45;
59 $val = $this->mParams[
'spellcheck'] ??
null;
60 if ( is_bool( $val ) ) {
62 return $val ?
'true' :
'false';
68 if ( isset( $this->mParams[
'persistent'] ) ) {
69 return $this->mParams[
'persistent'];
72 return !( isset( $this->mParams[
'type'] ) && $this->mParams[
'type'] ===
'password' );
93 if ( $this->mClass !==
'' ) {
96 if ( $this->mPlaceholder !==
'' ) {
100 # @todo Enforce pattern, step, required, readonly on the server side as
124 $type = $this->
getType( $attribs );
126 $inputHtml = Html::input( $this->mName, $value, $type, $attribs );
131 $type = $attribs[
'type'] ??
'text';
132 unset( $attribs[
'type'] );
134 # Implement tiny differences between some field variants
135 # here, rather than creating a new class for each one which
136 # is essentially just a clone of this one.
137 if ( isset( $this->mParams[
'type'] ) ) {
138 switch ( $this->mParams[
'type'] ) {
141 $attribs[
'step'] = 1;
145 $attribs[
'step'] =
'any';
151 $type = $this->mParams[
'type'];
153 case 'textwithbutton':
154 $type = $this->mParams[
'inputtype'] ??
'text';
173 if ( $this->mClass !==
'' ) {
176 if ( $this->mPlaceholder !==
'' ) {
180 # @todo Enforce pattern, step, required, readonly on the server side as
202 $attribs += \OOUI\Element::configFromHtmlAttributes(
206 $type = $this->
getType( $attribs );
207 if ( isset( $attribs[
'step'] ) && $attribs[
'step'] ===
'any' ) {
208 $attribs[
'step'] =
null;
213 'name' => $this->mName,
216 'dir' => $this->mDir,
234 if ( $this->mPlaceholder !==
'' ) {
260 $type = $this->
getType( $attribs );
262 return static::buildCodexComponent( $value, $hasErrors, $type, $this->mName, $attribs );
277 $wrapperClass = [
'cdx-text-input' ];
279 $wrapperClass[] =
'cdx-text-input--status-error';
282 $inputAttribs[
'class'][] =
'cdx-text-input__input';
283 $inputHtml = Html::input( $name, $value, $type, $inputAttribs );
285 return Html::rawElement(
'div', [
'class' => $wrapperClass ], $inputHtml );
296 return new \OOUI\TextInputWidget(
$params );
311class_alias( HTMLTextField::class,
'HTMLTextField' );
array $params
The job parameters.
getInputHTML( $value)
This function must be implemented to return the HTML to generate the input object itself....
getInputCodex( $value, $hasErrors)
Same as getInputHTML, but for Codex.
bool $autocomplete
HTML autocomplete attribute.
getDataAttribs()
Returns an array of data-* attributes to add to the field.
static buildCodexComponent( $value, $hasErrors, $type, $name, $inputAttribs)
Build the markup of the Codex component.
getInputOOUI( $value)
Same as getInputHTML, but returns an OOUI object.Defaults to false, which getOOUI will interpret as "...