34 if ( isset( $params[
'autocomplete'] ) && is_bool( $params[
'autocomplete'] ) ) {
35 $params[
'autocomplete'] = $params[
'autocomplete'] ?
'on' :
'off';
38 parent::__construct( $params );
40 if ( isset( $params[
'placeholder-message'] ) ) {
41 $this->mPlaceholder = $this->
getMessage( $params[
'placeholder-message'] )->text();
42 } elseif ( isset( $params[
'placeholder'] ) ) {
43 $this->mPlaceholder = $params[
'placeholder'];
52 return $this->mParams[
'size'] ?? 45;
56 $val = $this->mParams[
'spellcheck'] ??
null;
57 if ( is_bool( $val ) ) {
59 return $val ?
'true' :
'false';
65 if ( isset( $this->mParams[
'persistent'] ) ) {
66 return $this->mParams[
'persistent'];
69 return !( isset( $this->mParams[
'type'] ) && $this->mParams[
'type'] ===
'password' );
90 if ( $this->mClass !==
'' ) {
93 if ( $this->mPlaceholder !==
'' ) {
97 # @todo Enforce pattern, step, required, readonly on the server side as
122 return Html::input( $this->mName, $value,
$type, $attribs );
126 $type = $attribs[
'type'] ??
'text';
127 unset( $attribs[
'type'] );
129 # Implement tiny differences between some field variants
130 # here, rather than creating a new class for each one which
131 # is essentially just a clone of this one.
132 if ( isset( $this->mParams[
'type'] ) ) {
133 switch ( $this->mParams[
'type'] ) {
136 $attribs[
'step'] = 1;
140 $attribs[
'step'] =
'any';
146 $type = $this->mParams[
'type'];
148 case 'textwithbutton':
149 $type = $this->mParams[
'inputtype'] ??
'text';
168 if ( $this->mClass !==
'' ) {
171 if ( $this->mPlaceholder !==
'' ) {
175 # @todo Enforce pattern, step, required, readonly on the server side as
197 $attribs += OOUI\Element::configFromHtmlAttributes(
202 if ( isset( $attribs[
'step'] ) && $attribs[
'step'] ===
'any' ) {
203 $attribs[
'step'] =
null;
208 'name' => $this->mName,
211 'dir' => $this->mDir,
223 return new OOUI\TextInputWidget( $params );
getInputHTML( $value)
This function must be implemented to return the HTML to generate the input object itself....
getInputOOUI( $value)
Same as getInputHTML, but returns an OOUI object.Defaults to false, which getOOUI will interpret as "...
getDataAttribs()
Returns an array of data-* attributes to add to the field.
bool $autocomplete
HTML autocomplete attribute.