diff options
author | Roan Kattouw <catrope@users.mediawiki.org> | 2011-10-31 14:41:02 +0000 |
---|---|---|
committer | Roan Kattouw <catrope@users.mediawiki.org> | 2011-10-31 14:41:02 +0000 |
commit | 386a2658fd007ac8a77bfd60b0c9288e7826f76f (patch) | |
tree | 70adac0e3e9fe585638a0579dc484b70a4e1feec /includes/HTMLForm.php | |
parent | a0a775a9b4bb1a5698af2eb848a312b41787b394 (diff) | |
download | mediawikicore-386a2658fd007ac8a77bfd60b0c9288e7826f76f.tar.gz mediawikicore-386a2658fd007ac8a77bfd60b0c9288e7826f76f.zip |
On the preferences form, make preferences and other items at the top level of a section (e.g. with 'section' => 'foo') appear above rather than below subsections (e.g. stuff with 'section' => 'foo/bar'). This seems like natural behavior to me, but for some reason HTMLForm had it the other way around. I left the default behavior unchanged in HTMLForm and changed it only in PreferencesForm.
This change is needed for my work on the Gadgets extension in the RL2 branch (one example is adding text on top of a preferences section using a dummy type=>'info' preference, you want that to show up on top, not after all the subsections). The targeted use case (sections that contain both subsections and form elements) does not occur for core preferences, and is very uncommon in extensions. I managed to find such uses in only 3 of them: CreateAPage (in unreachable code), Tasks and EditSimilar add preferences to core sections that also contain subsections.
Notes
Notes:
http://mediawiki.org/wiki/Special:Code/MediaWiki/101358
Diffstat (limited to 'includes/HTMLForm.php')
-rw-r--r-- | includes/HTMLForm.php | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/includes/HTMLForm.php b/includes/HTMLForm.php index 84ae9ed73114..f883967159d5 100644 --- a/includes/HTMLForm.php +++ b/includes/HTMLForm.php @@ -113,6 +113,15 @@ class HTMLForm extends ContextSource { protected $mButtons = array(); protected $mWrapperLegend = false; + + /** + * If true, sections that contain both fields and subsections will + * render their subsections before their fields. + * + * Subclasses may set this to false to render subsections after fields + * instead. + */ + protected $mSubSectionBeforeFields = true; /** * Build a new HTMLForm from an array of field attributes @@ -775,7 +784,11 @@ class HTMLForm extends ContextSource { $tableHtml = Html::rawElement( 'table', $attribs, Html::rawElement( 'tbody', array(), "\n$tableHtml\n" ) ) . "\n"; - return $subsectionHtml . "\n" . $tableHtml; + if ( $this->mSubSectionBeforeFields ) { + return $subsectionHtml . "\n" . $tableHtml; + } else { + return $tableHtml . "\n" . $subsectionHtml; + } } /** |