This commit changes the way how HTMLForm handles a Status object
when executed from a request. It now handles, beside the errors,
also the warnings of a Status object and prints them out, wrapped
in a warning box.
The LoginSignupPage uses this feature to show informative warnings
actually as warnings and not as more disturbing error messages.
Error messages should be reserved for errors and only for erros. An
AuthenticationProvider, which returns an UI AuthenticationResponse
can choose, if the given message is an error or a warning message.
This commit also addds a new function to Status, which allows a
developer to split the object into two new Status objects, where one only
contains the errors and the other only the warnings of the origin
Status object (splitByErrorType). StatusValue also has a new function,
splitByErrorType(), to support this.
Bug: T139179
Change-Id: I9a27911613e62b5c4cb86bea40696cb37c4f49c2
ObjectFactory has a hack that constructs an object directly if there are
less than 10 parameters, which there typically is for HTMLForm classes.
This is faster than using ReflectionClass, and whenever ObjectFactory is
updated to take advantage of the splat operator, this will automatically
use it as well.
And use ::class while we're at it.
Change-Id: I7a696c127c237713448b165b9b4faee13f4ff88e
Calling HTMLForm::setFormIdentifier() will set an internal identifier
for this form. It will be submitted as a hidden form field, allowing
HTMLForm to determine whether the form was submitted (or just viewed).
Setting this serves two purposes:
* If you use two or more forms on one page, it allows HTMLForm to
identify which of the forms was submitted, and not attempt to
validate the other ones. (T102114)
* If you use checkbox or multiselect fields inside a form using the
GET method, it allows HTMLForm to distinguish between the initial
page view and a form submission with all checkboxes or select
options unchecked. (T29676)
Bug: T102114
Bug: T29676
Change-Id: Ib6ce3fd8941be86211cff5c6932b5e84982490fa
Add two new HTMLForm methods:
* showCancel( [bool] ) to display a cancel button
* setCancelTarget( Title|string ) to set where it should take
the user.
The cancel button is a simple link formatted as a button.
This is faster than a real button (skips an unnecessary
submit and redirect) and avoids some UX problems:
* when clicking on a real button, HTML5 or JS validators
might prevent submission, which does not make sense for cancel
* form field values might get saved by the brower, which again
does not make sense for cancelling
Use the cancel button for Special:ChangeCredentials.
Bug: T136809
Change-Id: Ieb80e2ff36751abc6f00e2a02926fe9800666a8b
'notice', 'notice-message' and 'notice-messages' can be used
as a parameter to the HTMLForm field to show the notices.
Only added implementation for OOUI forms because I'm not sure
what to do for others.
Bug: T104423
Change-Id: I512f3936bc3335df1bdf76505cfc39da6be99bed
Improves Ida647973a which unified message handling for form fields
but did not make the functionality available to HTMLForm itself.
Change-Id: I2e6195ba13afbd8b993acb47409fab1be91c547e
Fix a test in If4e0dfb : in the unlikely but valid case when
some form field object returns null from loadDataFromRequest,
handle it correctly and do not replace it with the default value.
Bug: T133163
Change-Id: Id8b48cfc6288d11a79a5838e72bb80b14137a7b0
Visually, this only affects OOUIHTMLForm, in other kinds of forms
the element has no height anyway.
Change-Id: I90e73c49fbefec23532368848bb30b2e7b69075c
- do not return anything when the button was not clicked
- return boolean true (instead of the button text) when it was clicked
Unbreaks submit fields which currently don't return anything so there is
no easy way to tell whether they have been clicked.
Change-Id: If4e0dfb6ee6674f0dace80a01850e2d0cbbdb47a
*-message(s) settings were documented as message key strings or arrays
of message key strings, but some actually accepted [key, params...]
arrays as well. They did not accept Message objects, which would be
the cleanest and most flexible method of message passing.
The patch adds a new method to process these settings (which accepts
a messages key, a [key, params...] array or a Message object), and
makes all *-message(s) usage call that.
Change-Id: Ida647973a58bea83fdbd53335e63b5a8615c16e4
This change adds a new method setAutocomplete to the class HTMLForm.
This method allows to set the HTML attribute autocomplete for the form.
This change uses this method to set autocomplete="off" for the preferences form.
Without autocomplete="off" the selections in the preferences get cached in
the browser. This can lead to wrong selected options when the settings get
changed on an other way, for example via API.
Bug: T131047
Change-Id: I2920383b5b8cfca3f1d546315f202985edf417d8
This reverts commit bc9b2162cb.
Just in case, this change[1] isn't merged before the next wmf-release (12 January) to unbreak the form.
[1] I3e0c02155428ae400bc3a6d3ed2e66e69ee441fa
Change-Id: I1a594485fbf8c75b4199df2e255dedc7fb90e74d
It already used HTMLForm for the main form, but the form, which asked for
the username didn't.
Converted the "Enter username" form to use HTMLForm and show it, if no user-
name was passed to the form, show the main "Send e-mail" form, instead.
Extra points:
- Let HTMLForm::setSubmit*() function return it's own HTMLForm instance
Bug: T117791
Change-Id: I6231577047c93781496e0f8af6809e2ef49e662a
Extra points:
* Add error message, when $input was not fiven (previous behaviour was, that
the form was simply displayed again.
Bug: T117748
Change-Id: Ibe4e010fe9d0b2520c2d6964bd66cb2bca3b0bc7
Submit buttons, whether via HTMLForm::addButton() or HTMLSubmitField,
are difficult to use effectively when the submitted value has to match
the internationalized display label. HTML5 (and HTML4 for that matter)
already has <button> that does what we need, we just need to actually
use it.
But for IE6 and IE7, we can't use <button> because the browser doesn't
handle them correctly. Sniff those browsers to avoid their bugginess
(which the OOUI version should have been doing already for IE6, but
wasn't).
Bug: T121584
Change-Id: I7e15331efb162275c4116bcae61f19d6b884cbe3
It's a dropdown select with the ability to add custom options, or a
text field with input suggestions, whichever you prefer.
This is meant to be a replacement for HTMLSelectOrOtherField and
HTMLAutoCompleteSelectField.
In regular HTML mode, it uses HTML5 `<datalist>` element with no
custom JavaScript. This is supported by a wide range of browsers
(IE 10+, modern Firefox and Chrome, Opera 12+).
In OOUI mode, it uses a ComboBoxInputWidget.
Depends on: I14b40884f185fb4e5
Bug: T118119
Change-Id: I954d3d24ed4efe90be9596a1bd9586ba3aee1e23
Hidden elements doesn't need an extra element in the DOM, but OOUIHTMLForm
would render one, wrapped into a fieldLayout div.
Fix this by adding the possibility to bypass the output, and only construct
a HTMLFormField element and run the output method.
Bug: T117768
Change-Id: I8c9d2ff862f1b14d72a9bb9e1a51e8745af6d1f4
HTMLFormField subclasses are supposed to handle error display but
some (like hidden fields) have no means of doing this. Add
a HTMLFormField::canDisplayErrors() method which can be overridden
to return false, in which case HTMLForm will take care of the
error display.
Also adds a 'rawmessage' message which can be used to wrap
arbitrary text. This can be passed to methods which expect a message
specifier array but do not allow a message object (so the RawMessage
class cannot be used), such as HTMLFormField::trySubmit().
Bug: T112635
Change-Id: I5d73536805774ff2ee0ec64b5442650c4888dc84
* Introduce a getter getHeaderText() and override it in OOUIHTMLForm.
* While we're at it, also introduce getFooterText() (although right
now we have no need to override this one).
* Use both in HTMLForm where appropriate.
Change-Id: I9a7234ed75b024f24e0a087c9c000bb2024b405f
* Introduce a new helper function formatSection() and override it
in OOUIHTMLForm.
* Bonus: Properly construct the form's FieldsetLayout,
thanks to I860a96858c4fcac62d63b46e35a9153f22c0a9c9.
* Bonus: Don't pass silly HTMLForm's classes which don't make
sense in OOUI mode.
Change-Id: I91af6efa8762e9676efea532381292e221255862
Issues with spacing (T107311), probably shouldn't have
been merged right before the branch cut.
This reverts commit 9508c5bd57.
Change-Id: Ibf2ca5a33b8ab0f7381c720c6c92fbfd7a7c819d