HomePhabricator

HTMLForm: Separate VForm code to a subclass

Authored by matmarex.

Description

HTMLForm: Separate VForm code to a subclass

…and in general, work with the existing HTMLForm design for defining
display formats, rather than against it.

Breaking changes:

  • HTMLForm::isVForm() is now deprecated.
  • You can no longer do this: $form = new HTMLForm( … ); $form->setDisplayFormat( 'vform' ); // throws exception Instead, do this: $form = HTMLForm::factory( 'vform', … ); When using FormSpecialPage, override the new getDisplayFormat() method instead of calling $form->setDisplayFormat() in the alterForm() method. (Other display formats are not affected, only 'vform'.)

Bug fixes:

  • Correctly suppress empty labels for VForm fields
  • Correctly disable <fieldset/> wrappers for VForms

Other benefits:

  • Reduce code duplication related to $getFieldHtmlMethod
  • Introduce HTMLForm::factory() method for constructing HTMLForms

Related cleanup:

  • Correctly style 'reset' buttons in MediaWiki UI mode
  • Label $wgHTMLFormAllowTableFormat as a mobile-specific hack
  • Display checkboxes normally in MediaWiki UI mode (removed weird override that only broke things). Also, always render checkboxes in VForms as .mw-ui-checkbox.
  • self:: → static::

Bug: T85285
Change-Id: I086a84f1c8cc6a16710709b7806c7f5f96462b32