X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fhtmlform%2FHTMLButtonField.php;h=64fe7eda9b262d2f0bea74f46f203c5daf5c998f;hb=fbe9167b89baa2edb42eb1367aa860bb2d10cdba;hp=211089f765cb1f1937d80c8b68f66647ece46466;hpb=fb7b3eebeb8de47eb42e8d6ccf204106a2d6d9e4;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/htmlform/HTMLButtonField.php b/includes/htmlform/HTMLButtonField.php index 211089f765..64fe7eda9b 100644 --- a/includes/htmlform/HTMLButtonField.php +++ b/includes/htmlform/HTMLButtonField.php @@ -6,7 +6,7 @@ * wish to add a submit button to a form. * * Additional recognized configuration parameters include: - * - flags: OOUI flags for the button, see OOUI\\FlaggedElement + * - flags: OOUI flags for the button, see OOUI\FlaggedElement * - buttonlabel-message: Message to use for the button display text, instead * of the value from 'default'. Overrides 'buttonlabel' and 'buttonlabel-raw'. * - buttonlabel: Text to display for the button display text, instead @@ -35,16 +35,7 @@ class HTMLButtonField extends HTMLFormField { # Generate the label from a message, if possible if ( isset( $info['buttonlabel-message'] ) ) { - $msgInfo = $info['buttonlabel-message']; - - if ( is_array( $msgInfo ) ) { - $msg = array_shift( $msgInfo ); - } else { - $msg = $msgInfo; - $msgInfo = []; - } - - $this->buttonLabel = $this->msg( $msg, $msgInfo )->parse(); + $this->buttonLabel = $this->getMessage( $info['buttonlabel-message'] )->parse(); } elseif ( isset( $info['buttonlabel'] ) ) { if ( $info['buttonlabel'] === ' ' ) { // Apparently some things set   directly and in an odd format @@ -56,6 +47,8 @@ class HTMLButtonField extends HTMLFormField { $this->buttonLabel = $info['buttonlabel-raw']; } + $this->setShowEmptyLabel( false ); + parent::__construct( $info ); } @@ -77,13 +70,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() ) ); } } @@ -95,16 +89,18 @@ 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, 'flags' => $this->mFlags, 'useInputTag' => $this->isBadIE(), - ] + $this->getAttributes( [ 'disabled', 'tabindex' ], [ 'tabindex' => 'tabIndex' ] ) ); + ] + OOUI\Element::configFromHtmlAttributes( + $this->getAttributes( [ 'disabled', 'tabindex' ] ) + ) ); } protected function needsLabel() {