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
121 $type = $this->
getType( $attribs );
122 $isCodexForm = $this->mParent && $this->mParent instanceof
CodexHTMLForm;
123 if ( $isCodexForm ) {
124 $class = $attribs[
'class'] ?? [];
125 if ( is_string( $class ) ) {
126 $attribs[
'class'] .=
' cdx-text-input__input';
128 $class[] =
'cdx-text-input__input';
129 $attribs[
'class'] = $class;
132 $inputHtml = Html::input( $this->mName, $value, $type, $attribs );
134 ? Html::rawElement(
'div', [
'class' =>
'cdx-text-input' ], $inputHtml )
139 $type = $attribs[
'type'] ??
'text';
140 unset( $attribs[
'type'] );
142 # Implement tiny differences between some field variants
143 # here, rather than creating a new class for each one which
144 # is essentially just a clone of this one.
145 if ( isset( $this->mParams[
'type'] ) ) {
146 switch ( $this->mParams[
'type'] ) {
149 $attribs[
'step'] = 1;
153 $attribs[
'step'] =
'any';
159 $type = $this->mParams[
'type'];
161 case 'textwithbutton':
162 $type = $this->mParams[
'inputtype'] ??
'text';
181 if ( $this->mClass !==
'' ) {
184 if ( $this->mPlaceholder !==
'' ) {
188 # @todo Enforce pattern, step, required, readonly on the server side as
210 $attribs += OOUI\Element::configFromHtmlAttributes(
214 $type = $this->
getType( $attribs );
215 if ( isset( $attribs[
'step'] ) && $attribs[
'step'] ===
'any' ) {
216 $attribs[
'step'] =
null;
221 'name' => $this->mName,
224 'dir' => $this->mDir,
236 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.