X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fhtmlform%2Ffields%2FHTMLTextField.php;h=1c5a43ddad41275784fc3006d24c242319a192a7;hb=34dae4452f57219d555e2b6989357cd2cca54f72;hp=88f5ec586ca4dcff31fb0947f358dcfd38dfe8a0;hpb=37751ee23e7b7019307eafe36f18c8450bf2e420;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/htmlform/fields/HTMLTextField.php b/includes/htmlform/fields/HTMLTextField.php index 88f5ec586c..1c5a43ddad 100644 --- a/includes/htmlform/fields/HTMLTextField.php +++ b/includes/htmlform/fields/HTMLTextField.php @@ -1,8 +1,19 @@ field. + * + * Besides the parameters recognized by HTMLFormField, the following are + * recognized: + * autocomplete - HTML autocomplete value (a boolean for on/off or a string according to + * https://html.spec.whatwg.org/multipage/forms.html#autofill ) + */ class HTMLTextField extends HTMLFormField { protected $mPlaceholder = ''; + /** @var bool HTML autocomplete attribute */ + protected $autocomplete; + /** * @param array $params * - type: HTML textfield type @@ -13,6 +24,10 @@ class HTMLTextField extends HTMLFormField { * for password fields) */ public function __construct( $params ) { + if ( isset( $params['autocomplete'] ) && is_bool( $params['autocomplete'] ) ) { + $params['autocomplete'] = $params['autocomplete'] ? 'on' : 'off'; + } + parent::__construct( $params ); if ( isset( $params['placeholder-message'] ) ) { @@ -80,7 +95,8 @@ class HTMLTextField extends HTMLFormField { 'required', 'autofocus', 'multiple', - 'readonly' + 'readonly', + 'autocomplete', ]; $attribs += $this->getAttributes( $allowedParams ); @@ -124,7 +140,7 @@ class HTMLTextField extends HTMLFormField { $value = ''; } - $attribs = $this->getTooltipAndAccessKey(); + $attribs = $this->getTooltipAndAccessKeyOOUI(); if ( $this->mClass !== '' ) { $attribs['classes'] = [ $this->mClass ]; @@ -146,12 +162,24 @@ class HTMLTextField extends HTMLFormField { 'required', 'tabindex', 'type', + 'autocomplete', ]; $attribs += OOUI\Element::configFromHtmlAttributes( $this->getAttributes( $allowedParams ) ); + // FIXME T150983 downgrade autocomplete + if ( isset( $attribs['autocomplete'] ) ) { + if ( $attribs['autocomplete'] === 'on' ) { + $attribs['autocomplete'] = true; + } elseif ( $attribs['autocomplete'] === 'off' ) { + $attribs['autocomplete'] = false; + } else { + unset( $attribs['autocomplete'] ); + } + } + $type = $this->getType( $attribs ); return $this->getInputWidget( [ @@ -159,6 +187,7 @@ class HTMLTextField extends HTMLFormField { 'name' => $this->mName, 'value' => $value, 'type' => $type, + 'dir' => $this->mDir, ] + $attribs ); }