X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fhtmlform%2Ffields%2FHTMLTextField.php;h=c1955975ce995fb2dc9d7c59e07b1c1fe581da01;hb=8f17b09a9fd04ed673a1e0c184d0ecf1926270a6;hp=3ab71766962ad2be76e30a98f4e8018190a30e36;hpb=6ff5f4ef32e686918676463c3da5c745b574d2ba;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/htmlform/fields/HTMLTextField.php b/includes/htmlform/fields/HTMLTextField.php index 3ab7176696..c1955975ce 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 ); @@ -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( [