35 if ( isset( $params[
'autocomplete'] ) && is_bool( $params[
'autocomplete'] ) ) {
36 $params[
'autocomplete'] = $params[
'autocomplete'] ?
'on' :
'off';
39 parent::__construct( $params );
41 if ( isset( $params[
'placeholder-message'] ) ) {
42 $this->mPlaceholder = $this->
getMessage( $params[
'placeholder-message'] )->text();
43 } elseif ( isset( $params[
'placeholder'] ) ) {
44 $this->mPlaceholder = $params[
'placeholder'];
53 return $this->mParams[
'size'] ?? 45;
60 $val = $this->mParams[
'spellcheck'] ??
null;
61 if ( is_bool( $val ) ) {
63 return $val ?
'true' :
'false';
72 if ( isset( $this->mParams[
'persistent'] ) ) {
73 return $this->mParams[
'persistent'];
76 return !( isset( $this->mParams[
'type'] ) && $this->mParams[
'type'] ===
'password' );
97 if ( $this->mClass !==
'' ) {
100 if ( $this->mPlaceholder !==
'' ) {
104 # @todo Enforce pattern, step, required, readonly on the server side as
129 $type = $this->
getType( $attribs );
131 $inputHtml = Html::input( $this->mName, $value, $type, $attribs );
140 $type = $attribs[
'type'] ??
'text';
141 unset( $attribs[
'type'] );
143 # Implement tiny differences between some field variants
144 # here, rather than creating a new class for each one which
145 # is essentially just a clone of this one.
146 if ( isset( $this->mParams[
'type'] ) ) {
147 switch ( $this->mParams[
'type'] ) {
150 $attribs[
'step'] = 1;
154 $attribs[
'step'] =
'any';
160 $type = $this->mParams[
'type'];
162 case 'textwithbutton':
163 $type = $this->mParams[
'inputtype'] ??
'text';
182 if ( $this->mClass !==
'' ) {
185 if ( $this->mPlaceholder !==
'' ) {
189 # @todo Enforce pattern, step, required, readonly on the server side as
212 $attribs += \OOUI\Element::configFromHtmlAttributes(
216 $type = $this->
getType( $attribs );
217 if ( isset( $attribs[
'step'] ) && $attribs[
'step'] ===
'any' ) {
218 $attribs[
'step'] =
null;
223 'name' => $this->mName,
226 'dir' => $this->mDir,
245 if ( $this->mPlaceholder !==
'' ) {
272 $type = $this->
getType( $attribs );
274 return static::buildCodexComponent( $value, $hasErrors, $type, $this->mName, $attribs );
289 $wrapperClass = [
'cdx-text-input' ];
291 $wrapperClass[] =
'cdx-text-input--status-error';
294 $inputAttribs[
'class'][] =
'cdx-text-input__input';
295 $inputHtml = Html::input( $name, $value, $type, $inputAttribs );
297 return Html::rawElement(
'div', [
'class' => $wrapperClass ], $inputHtml );
308 return new \OOUI\TextInputWidget( $params );
323class_alias( HTMLTextField::class,
'HTMLTextField' );
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.This is called by CodexHTMLForm.If not overridden,...
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 "...