OOUIHTMLForm: Make boolean form field parameters actually work everywhere
authorBartosz Dziewoński <matma.rex@gmail.com>
Tue, 1 Sep 2015 13:03:07 +0000 (15:03 +0200)
committerBartosz Dziewoński <matma.rex@gmail.com>
Tue, 1 Sep 2015 13:16:52 +0000 (13:16 +0000)
commitdd04b310527c3ce69911789254939e9a2b627ada
tree5e756d83c2c0188102d4d4573654e6c83a26bf3b
parentc0ee3dd1d906e735fddccdc6754e00ea35844146
OOUIHTMLForm: Make boolean form field parameters actually work everywhere

HTMLFormField::getAttributes() is unfortunately reused both for
generating HTML tag attributes and generating OOUI widget
configuration. For boolean ones passing '' for true (empty string)
works for HTML (where the attribute only has to be present), but not
for OOUI (where the configuration option has to be truthy).

It would be cleanest to pass true/false, which is the expected input
for OOUI widgets and which the Html class handles intuitively, but it
seems that these values often end up in the Xml class's methods
instead (somebody remind me why do we even have that?). So let's play
it safe and pass the name of the parameter instead, which is okay for
both HTML/XML (both disabled="" and disabled="disabled" work the same)
and OOUI widgets.

(Note also that the whole thing relies on the default value of these
boolean parameters/attributes being false.)

This was not spotted before because we had hacks for this problem in
all the important places. This commit reverts three such hacky
patches that missed the underlying problem:

e25eb30ea81eda82b57a4e3c84f4e1afdf3b6080
70910cd13cdb5d67f1dda2d9ccffbc8e30787352
8a164ff9f9f5b4691e40f1219358ca45c8b61c3d

Change-Id: Ic6a1f3758cba62147f7fe8127cc0a83c695b0212
includes/htmlform/HTMLFormField.php
includes/htmlform/HTMLTextAreaField.php
includes/htmlform/HTMLTextField.php