38 if ( isset( $params[
'autocomplete'] ) && is_bool( $params[
'autocomplete'] ) ) {
39 $params[
'autocomplete'] = $params[
'autocomplete'] ?
'on' :
'off';
42 parent::__construct( $params );
44 if ( isset( $params[
'placeholder-message'] ) ) {
45 $this->mPlaceholder = $this->
getMessage( $params[
'placeholder-message'] )->text();
46 } elseif ( isset( $params[
'placeholder'] ) ) {
47 $this->mPlaceholder = $params[
'placeholder'];
56 return $this->mParams[
'size'] ?? 45;
63 $val = $this->mParams[
'spellcheck'] ??
null;
64 if ( is_bool( $val ) ) {
66 return $val ?
'true' :
'false';
75 if ( isset( $this->mParams[
'persistent'] ) ) {
76 return $this->mParams[
'persistent'];
79 return !( isset( $this->mParams[
'type'] ) && $this->mParams[
'type'] ===
'password' );
100 if ( $this->mClass !==
'' ) {
103 if ( $this->mPlaceholder !==
'' ) {
107 # @todo Enforce pattern, step, required, readonly on the server side as
132 $type = $this->
getType( $attribs );
134 $inputHtml = Html::input( $this->mName, $value, $type, $attribs );
143 $type = $attribs[
'type'] ??
'text';
144 unset( $attribs[
'type'] );
146 # Implement tiny differences between some field variants
147 # here, rather than creating a new class for each one which
148 # is essentially just a clone of this one.
149 if ( isset( $this->mParams[
'type'] ) ) {
150 switch ( $this->mParams[
'type'] ) {
153 $attribs[
'step'] = 1;
157 $attribs[
'step'] =
'any';
163 $type = $this->mParams[
'type'];
165 case 'textwithbutton':
166 $type = $this->mParams[
'inputtype'] ??
'text';
185 if ( $this->mClass !==
'' ) {
188 if ( $this->mPlaceholder !==
'' ) {
192 # @todo Enforce pattern, step, required, readonly on the server side as
215 $attribs += \OOUI\Element::configFromHtmlAttributes(
219 $type = $this->
getType( $attribs );
220 if ( isset( $attribs[
'step'] ) && $attribs[
'step'] ===
'any' ) {
221 $attribs[
'step'] =
null;
226 'name' => $this->mName,
229 'dir' => $this->mDir,
247 if ( $this->mPlaceholder !==
'' ) {
274 $type = $this->
getType( $attribs );
276 return static::buildCodexComponent( $value, $hasErrors, $type, $this->mName, $attribs );
291 $wrapperClass = [
'cdx-text-input' ];
293 $wrapperClass[] =
'cdx-text-input--status-error';
296 $inputAttribs[
'class'][] =
'cdx-text-input__input';
297 $inputHtml = Html::input( $name, $value, $type, $inputAttribs );
299 return Html::rawElement(
'div', [
'class' => $wrapperClass ], $inputHtml );
310 return new \OOUI\TextInputWidget( $params );
325class_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.
bool $autocomplete
HTML autocomplete attribute.
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 "...