From: Gergő Tisza Date: Fri, 1 Apr 2016 11:49:49 +0000 (+0300) Subject: Use default value instead of submitted value in HTMLForm buttons X-Git-Tag: 1.31.0-rc.0~7458^2 X-Git-Url: http://git.heureux-cyclage.org/?a=commitdiff_plain;h=1705c6f9076c58e572953540b1cb20dc5be1b7d1;hp=718f3f78b583a473035f39a8c46e0a9829d2e0bf;p=lhc%2Fweb%2Fwiklou.git Use default value instead of submitted value in HTMLForm buttons In some exotic use cases where the form is rendered straight from a successful submit this prevents unexpected button text changes. Change-Id: I61619b6222d9fb29c63ce7c1f3ceff512143c4f7 --- diff --git a/includes/htmlform/HTMLButtonField.php b/includes/htmlform/HTMLButtonField.php index 16417fc4b5..1c4daf3b7a 100644 --- a/includes/htmlform/HTMLButtonField.php +++ b/includes/htmlform/HTMLButtonField.php @@ -79,13 +79,14 @@ class HTMLButtonField extends HTMLFormField { 'id' => $this->mID, 'type' => $this->buttonType, 'name' => $this->mName, - 'value' => $value, + 'value' => $this->getDefault(), ] + $this->getAttributes( [ 'disabled', 'tabindex' ] ); if ( $this->isBadIE() ) { return Html::element( 'input', $attr ); } else { - return Html::rawElement( 'button', $attr, $this->buttonLabel ?: htmlspecialchars( $value ) ); + return Html::rawElement( 'button', $attr, + $this->buttonLabel ?: htmlspecialchars( $this->getDefault() ) ); } } @@ -97,10 +98,10 @@ class HTMLButtonField extends HTMLFormField { public function getInputOOUI( $value ) { return new OOUI\ButtonInputWidget( [ 'name' => $this->mName, - 'value' => $value, + 'value' => $this->getDefault(), 'label' => !$this->isBadIE() && $this->buttonLabel ? new OOUI\HtmlSnippet( $this->buttonLabel ) - : $value, + : $this->getDefault(), 'type' => $this->buttonType, 'classes' => [ 'mw-htmlform-submit', $this->mClass ], 'id' => $this->mID,