From: Alexandre Emsenhuber Date: Mon, 29 Apr 2013 06:13:05 +0000 (+0200) Subject: Allow setting the ID of the main table in HTMLForm X-Git-Tag: 1.31.0-rc.0~19565^2 X-Git-Url: http://git.cyclocoop.org/fichier?a=commitdiff_plain;h=fcf98dc451af81ca0099e58729f2d16d85710daf;p=lhc%2Fweb%2Fwiklou.git Allow setting the ID of the main table in HTMLForm - Added new method HTMLForm::setTableId() to allow to set the ID of the main table (or the outermost
element depending on the format). - Changed the second parameter of HTMLForm::displaySection() to take the full ID so that the one set with setTableId() will not get prefixed with "mw-htmlform-" Note: If someone has a better idea for the name of that method (since it also applies to
elements), please tell me it :) Change-Id: Id01bd0fa44512b0320f3c3ff79627e8a9bccd5bb --- diff --git a/includes/HTMLForm.php b/includes/HTMLForm.php index 5e3bb0657a..2bf7436839 100644 --- a/includes/HTMLForm.php +++ b/includes/HTMLForm.php @@ -140,6 +140,7 @@ class HTMLForm extends ContextSource { protected $mSectionFooters = array(); protected $mPost = ''; protected $mId; + protected $mTableId = ''; protected $mSubmitID; protected $mSubmitName; @@ -742,7 +743,7 @@ class HTMLForm extends ContextSource { * @return String */ function getBody() { - return $this->displaySection( $this->mFieldTree ); + return $this->displaySection( $this->mFieldTree, $this->mTableId ); } /** @@ -871,6 +872,18 @@ class HTMLForm extends ContextSource { return $this; } + /** + * Set the id of the \ or outermost \ element. + * + * @since 1.22 + * @param string $id new value of the id attribute, or "" to remove + * @return HTMLForm $this for chaining calls + */ + public function setTableId( $id ) { + $this->mTableId = $id; + return $this; + } + /** * @param string $id DOM id for the form * @return HTMLForm $this for chaining calls (since 1.20) @@ -879,6 +892,7 @@ class HTMLForm extends ContextSource { $this->mId = $id; return $this; } + /** * Prompt the whole form to be wrapped in a "
", with * this text as its "" element. @@ -977,7 +991,7 @@ class HTMLForm extends ContextSource { $hasLabel = true; } } elseif ( is_array( $value ) ) { - $section = $this->displaySection( $value, $key, "$fieldsetIDPrefix$key-" ); + $section = $this->displaySection( $value, "mw-htmlform-$key", "$fieldsetIDPrefix$key-" ); $legend = $this->getLegend( $key ); if ( isset( $this->mSectionHeaders[$key] ) ) { $section = $this->mSectionHeaders[$key] . $section; @@ -1005,7 +1019,7 @@ class HTMLForm extends ContextSource { ); if ( $sectionName ) { - $attribs['id'] = Sanitizer::escapeId( "mw-htmlform-$sectionName" ); + $attribs['id'] = Sanitizer::escapeId( $sectionName ); } if ( $displayFormat === 'table' ) {