X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fhtmlform%2FHTMLForm.php;h=78e7625915ba7b877a1192e1eed0f2b948c09141;hb=ee56f00ddf0609082f8ae9a4dc3e6e1b6f54ddfd;hp=d959dd2adcf2424df56747eb76ec535cdd8f0776;hpb=23673a0ff99f4173ded689ee32dae799f2d07642;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/htmlform/HTMLForm.php b/includes/htmlform/HTMLForm.php index d959dd2adc..78e7625915 100644 --- a/includes/htmlform/HTMLForm.php +++ b/includes/htmlform/HTMLForm.php @@ -21,6 +21,8 @@ * @file */ +use Wikimedia\ObjectFactory; + /** * Object handling generic submission, CSRF protection, layout and * other logic for UI forms. in a reusable manner. @@ -128,44 +130,44 @@ class HTMLForm extends ContextSource { // A mapping of 'type' inputs onto standard HTMLFormField subclasses public static $typeMappings = [ - 'api' => 'HTMLApiField', - 'text' => 'HTMLTextField', - 'textwithbutton' => 'HTMLTextFieldWithButton', - 'textarea' => 'HTMLTextAreaField', - 'select' => 'HTMLSelectField', - 'combobox' => 'HTMLComboboxField', - 'radio' => 'HTMLRadioField', - 'multiselect' => 'HTMLMultiSelectField', - 'limitselect' => 'HTMLSelectLimitField', - 'check' => 'HTMLCheckField', - 'toggle' => 'HTMLCheckField', - 'int' => 'HTMLIntField', - 'float' => 'HTMLFloatField', - 'info' => 'HTMLInfoField', - 'selectorother' => 'HTMLSelectOrOtherField', - 'selectandother' => 'HTMLSelectAndOtherField', - 'namespaceselect' => 'HTMLSelectNamespace', - 'namespaceselectwithbutton' => 'HTMLSelectNamespaceWithButton', - 'tagfilter' => 'HTMLTagFilter', - 'sizefilter' => 'HTMLSizeFilterField', - 'submit' => 'HTMLSubmitField', - 'hidden' => 'HTMLHiddenField', - 'edittools' => 'HTMLEditTools', - 'checkmatrix' => 'HTMLCheckMatrix', - 'cloner' => 'HTMLFormFieldCloner', - 'autocompleteselect' => 'HTMLAutoCompleteSelectField', - 'date' => 'HTMLDateTimeField', - 'time' => 'HTMLDateTimeField', - 'datetime' => 'HTMLDateTimeField', + 'api' => HTMLApiField::class, + 'text' => HTMLTextField::class, + 'textwithbutton' => HTMLTextFieldWithButton::class, + 'textarea' => HTMLTextAreaField::class, + 'select' => HTMLSelectField::class, + 'combobox' => HTMLComboboxField::class, + 'radio' => HTMLRadioField::class, + 'multiselect' => HTMLMultiSelectField::class, + 'limitselect' => HTMLSelectLimitField::class, + 'check' => HTMLCheckField::class, + 'toggle' => HTMLCheckField::class, + 'int' => HTMLIntField::class, + 'float' => HTMLFloatField::class, + 'info' => HTMLInfoField::class, + 'selectorother' => HTMLSelectOrOtherField::class, + 'selectandother' => HTMLSelectAndOtherField::class, + 'namespaceselect' => HTMLSelectNamespace::class, + 'namespaceselectwithbutton' => HTMLSelectNamespaceWithButton::class, + 'tagfilter' => HTMLTagFilter::class, + 'sizefilter' => HTMLSizeFilterField::class, + 'submit' => HTMLSubmitField::class, + 'hidden' => HTMLHiddenField::class, + 'edittools' => HTMLEditTools::class, + 'checkmatrix' => HTMLCheckMatrix::class, + 'cloner' => HTMLFormFieldCloner::class, + 'autocompleteselect' => HTMLAutoCompleteSelectField::class, + 'date' => HTMLDateTimeField::class, + 'time' => HTMLDateTimeField::class, + 'datetime' => HTMLDateTimeField::class, // HTMLTextField will output the correct type="" attribute automagically. // There are about four zillion other HTML5 input types, like range, but // we don't use those at the moment, so no point in adding all of them. - 'email' => 'HTMLTextField', - 'password' => 'HTMLTextField', - 'url' => 'HTMLTextField', - 'title' => 'HTMLTitleTextField', - 'user' => 'HTMLUserTextField', - 'usersmultiselect' => 'HTMLUsersMultiselectField', + 'email' => HTMLTextField::class, + 'password' => HTMLTextField::class, + 'url' => HTMLTextField::class, + 'title' => HTMLTitleTextField::class, + 'user' => HTMLUserTextField::class, + 'usersmultiselect' => HTMLUsersMultiselectField::class, ]; public $mFieldData; @@ -213,11 +215,11 @@ class HTMLForm extends ContextSource { protected $mAction = false; /** - * Form attribute autocomplete. false does not set the attribute + * Form attribute autocomplete. A typical value is "off". null does not set the attribute * @since 1.27 - * @var bool|string + * @var string|null */ - protected $mAutocomplete = false; + protected $mAutocomplete = null; protected $mUseMultipart = false; protected $mHiddenFields = []; @@ -1062,7 +1064,7 @@ class HTMLForm extends ContextSource { if ( $this->mId ) { $attribs['id'] = $this->mId; } - if ( $this->mAutocomplete ) { + if ( is_string( $this->mAutocomplete ) ) { $attribs['autocomplete'] = $this->mAutocomplete; } if ( $this->mName ) { @@ -1868,12 +1870,12 @@ class HTMLForm extends ContextSource { } /** - * Set the value for the autocomplete attribute of the form. - * When set to false (which is the default state), the attribute get not set. + * Set the value for the autocomplete attribute of the form. A typical value is "off". + * When set to null (which is the default state), the attribute get not set. * * @since 1.27 * - * @param string|bool $autocomplete + * @param string|null $autocomplete * * @return HTMLForm $this for chaining calls */