3 class HTMLTextField
extends HTMLFormField
{
5 return isset( $this->mParams
['size'] ) ?
$this->mParams
['size'] : 45;
8 function getSpellCheck() {
9 $val = isset( $this->mParams
['spellcheck'] ) ?
$this->mParams
['spellcheck'] : null;
10 if ( is_bool( $val ) ) {
11 // "spellcheck" attribute literally requires "true" or "false" to work.
12 return $val === true ?
'true' : 'false';
17 function getInputHTML( $value ) {
20 'name' => $this->mName
,
21 'size' => $this->getSize(),
24 'spellcheck' => $this->getSpellCheck(),
25 ) +
$this->getTooltipAndAccessKey();
27 if ( $this->mClass
!== '' ) {
28 $attribs['class'] = $this->mClass
;
31 # @todo Enforce pattern, step, required, readonly on the server side as
33 $allowedParams = array(
51 $attribs +
= $this->getAttributes( $allowedParams );
54 $type = $this->getType( $attribs );
55 return Html
::input( $this->mName
, $value, $type, $attribs );
58 protected function getType( &$attribs ) {
59 $type = isset( $attribs['type'] ) ?
$attribs['type'] : 'text';
60 unset( $attribs['type'] );
62 # Implement tiny differences between some field variants
63 # here, rather than creating a new class for each one which
64 # is essentially just a clone of this one.
65 if ( isset( $this->mParams
['type'] ) ) {
66 switch ( $this->mParams
['type'] ) {
72 $attribs['step'] = 'any';
79 $type = $this->mParams
['type'];
87 function getInputOOUI( $value ) {
88 $attribs = $this->getTooltipAndAccessKey();
90 if ( $this->mClass
!== '' ) {
91 $attribs['classes'] = array( $this->mClass
);
94 # @todo Enforce pattern, step, required, readonly on the server side as
96 $allowedParams = array(
110 $attribs +
= $this->getAttributes( $allowedParams, array(
111 'maxlength' => 'maxLength',
112 'readonly' => 'readOnly',
113 'tabindex' => 'tabIndex',
116 $type = $this->getType( $attribs );
118 return $this->getInputWidget( array(
120 'name' => $this->mName
,
126 protected function getInputWidget( $params ) {
127 return new OOUI\
TextInputWidget( $params );