27 if ( isset( $params[
'autocomplete'] ) && is_bool( $params[
'autocomplete'] ) ) {
28 $params[
'autocomplete'] = $params[
'autocomplete'] ?
'on' :
'off';
31 parent::__construct( $params );
33 if ( isset( $params[
'placeholder-message'] ) ) {
34 $this->mPlaceholder = $this->
getMessage( $params[
'placeholder-message'] )->text();
35 } elseif ( isset( $params[
'placeholder'] ) ) {
36 $this->mPlaceholder = $params[
'placeholder'];
41 return $this->mParams[
'size'] ?? 45;
45 $val = $this->mParams[
'spellcheck'] ?? null;
46 if ( is_bool( $val ) ) {
48 return $val ===
true ?
'true' :
'false';
54 if ( isset( $this->mParams[
'persistent'] ) ) {
55 return $this->mParams[
'persistent'];
58 return !( isset( $this->mParams[
'type'] ) && $this->mParams[
'type'] ===
'password' );
75 if ( $this->mClass !==
'' ) {
78 if ( $this->mPlaceholder !==
'' ) {
82 # @todo Enforce pattern, step, required, readonly on the server side as 111 $type = $attribs[
'type'] ??
'text';
112 unset( $attribs[
'type'] );
114 # Implement tiny differences between some field variants 115 # here, rather than creating a new class for each one which 116 # is essentially just a clone of this one. 117 if ( isset( $this->mParams[
'type'] ) ) {
118 switch ( $this->mParams[
'type'] ) {
121 $attribs[
'step'] = 1;
125 $attribs[
'step'] =
'any';
132 $type = $this->mParams[
'type'];
134 case 'textwithbutton':
135 $type = $this->mParams[
'inputtype'] ??
'text';
150 if ( $this->mClass !==
'' ) {
153 if ( $this->mPlaceholder !==
'' ) {
157 # @todo Enforce pattern, step, required, readonly on the server side as 178 $attribs += OOUI\Element::configFromHtmlAttributes(
183 if ( isset( $attribs[
'autocomplete'] ) ) {
184 if ( $attribs[
'autocomplete'] ===
'on' ) {
185 $attribs[
'autocomplete'] =
true;
186 } elseif ( $attribs[
'autocomplete'] ===
'off' ) {
187 $attribs[
'autocomplete'] =
false;
189 unset( $attribs[
'autocomplete'] );
194 if ( isset( $attribs[
'step'] ) && $attribs[
'step'] ===
'any' ) {
195 $attribs[
'step'] = null;
200 'name' => $this->mName,
203 'dir' => $this->mDir,
getDataAttribs()
Returns an array of data-* attributes to add to the field.
static input( $name, $value='', $type='text', array $attribs=[])
Convenience function to produce an "<input>" element.
bool $autocomplete
HTML autocomplete attribute.