38 if ( isset(
$params[
'autocomplete'] ) && is_bool(
$params[
'autocomplete'] ) ) {
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;
60 $val = $this->mParams[
'spellcheck'] ??
null;
61 if ( is_bool( $val ) ) {
63 return $val ?
'true' :
'false';
69 if ( isset( $this->mParams[
'persistent'] ) ) {
70 return $this->mParams[
'persistent'];
73 return !( isset( $this->mParams[
'type'] ) && $this->mParams[
'type'] ===
'password' );
94 if ( $this->mClass !==
'' ) {
97 if ( $this->mPlaceholder !==
'' ) {
101 # @todo Enforce pattern, step, required, readonly on the server side as
125 $type = $this->
getType( $attribs );
127 $inputHtml = Html::input( $this->mName, $value, $type, $attribs );
132 $type = $attribs[
'type'] ??
'text';
133 unset( $attribs[
'type'] );
135 # Implement tiny differences between some field variants
136 # here, rather than creating a new class for each one which
137 # is essentially just a clone of this one.
138 if ( isset( $this->mParams[
'type'] ) ) {
139 switch ( $this->mParams[
'type'] ) {
142 $attribs[
'step'] = 1;
146 $attribs[
'step'] =
'any';
152 $type = $this->mParams[
'type'];
154 case 'textwithbutton':
155 $type = $this->mParams[
'inputtype'] ??
'text';
174 if ( $this->mClass !==
'' ) {
177 if ( $this->mPlaceholder !==
'' ) {
181 # @todo Enforce pattern, step, required, readonly on the server side as
203 $attribs += \OOUI\Element::configFromHtmlAttributes(
207 $type = $this->
getType( $attribs );
208 if ( isset( $attribs[
'step'] ) && $attribs[
'step'] ===
'any' ) {
209 $attribs[
'step'] =
null;
214 'name' => $this->mName,
217 'dir' => $this->mDir,
235 if ( $this->mPlaceholder !==
'' ) {
261 $type = $this->
getType( $attribs );
263 return static::buildCodexComponent( $value, $hasErrors, $type, $this->mName, $attribs );
278 $wrapperClass = [
'cdx-text-input' ];
280 $wrapperClass[] =
'cdx-text-input--status-error';
283 $inputAttribs[
'class'][] =
'cdx-text-input__input';
284 $inputHtml = Html::input( $name, $value, $type, $inputAttribs );
286 return Html::rawElement(
'div', [
'class' => $wrapperClass ], $inputHtml );
297 return new \OOUI\TextInputWidget(
$params );
312class_alias( HTMLTextField::class,
'HTMLTextField' );
array $params
The job parameters.
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 "...