From: Alexandre Emsenhuber Date: Thu, 21 Nov 2013 07:45:34 +0000 (+0100) Subject: Fix HTML output arround HTMLForm's submit buttons when in vform X-Git-Tag: 1.31.0-rc.0~16974^2 X-Git-Url: http://git.cyclocoop.org/ecrire?a=commitdiff_plain;h=0311433ce51e41d5bd26e54d3caf4540e1d47b4d;p=lhc%2Fweb%2Fwiklou.git Fix HTML output arround HTMLForm's submit buttons when in vform $html in HTMLForm::getButtons() is vrapped in a
when in vform mode but it contains a tag without its closing counterpart, thus making the HTML invalid. And while I'm at it: put line breaks at better places. Change-Id: I7ffa1bdd72d95188320c1b29d1c46a5f6f434cbe --- diff --git a/includes/htmlform/HTMLForm.php b/includes/htmlform/HTMLForm.php index 5621b01f43..6af2f5f745 100644 --- a/includes/htmlform/HTMLForm.php +++ b/includes/htmlform/HTMLForm.php @@ -787,7 +787,7 @@ class HTMLForm extends ContextSource { * @return String HTML. */ function getButtons() { - $html = ''; + $buttons = ''; if ( $this->mShowSubmit ) { $attribs = array(); @@ -812,24 +812,17 @@ class HTMLForm extends ContextSource { array_push( $attribs['class'], 'mw-ui-button', 'mw-ui-big', 'mw-ui-primary', 'mw-ui-block' ); } - $html .= Xml::submitButton( $this->getSubmitText(), $attribs ) . "\n"; - - // Buttons are top-level form elements in table and div layouts, - // but vform wants all elements inside divs to get spaced-out block - // styling. - if ( $this->isVForm() ) { - $html = Html::rawElement( 'div', null, "\n$html\n" ); - } + $buttons .= Xml::submitButton( $this->getSubmitText(), $attribs ) . "\n"; } if ( $this->mShowReset ) { - $html .= Html::element( - 'input', - array( - 'type' => 'reset', - 'value' => $this->msg( 'htmlform-reset' )->text() - ) - ) . "\n"; + $buttons .= Html::element( + 'input', + array( + 'type' => 'reset', + 'value' => $this->msg( 'htmlform-reset' )->text() + ) + ) . "\n"; } foreach ( $this->mButtons as $button ) { @@ -847,10 +840,18 @@ class HTMLForm extends ContextSource { $attrs['id'] = $button['id']; } - $html .= Html::element( 'input', $attrs ); + $buttons .= Html::element( 'input', $attrs ) . "\n"; } - $html .= ''; + $html = Html::rawElement( 'span', + array( 'class' => 'mw-htmlform-submit-buttons' ), "\n$buttons" ) . "\n"; + + // Buttons are top-level form elements in table and div layouts, + // but vform wants all elements inside divs to get spaced-out block + // styling. + if ( $this->mShowSubmit && $this->isVForm() ) { + $html = Html::rawElement( 'div', null, "\n$html" ) . "\n"; + } return $html; }