) . "\n";
}
+ if ( $this->mShowCancel ) {
+ $target = $this->mCancelTarget ?: Title::newMainPage();
+ if ( $target instanceof Title ) {
+ $target = $target->getLocalURL();
+ }
+ $buttons .= Html::element(
+ 'a',
+ [
+ 'class' => 'mw-ui-button mw-ui-big mw-ui-block',
+ 'href' => $target,
+ ],
+ $this->msg( 'cancel' )->text()
+ ) . "\n";
+ }
+
foreach ( $this->mButtons as $button ) {
$attrs = [
'type' => 'submit',
$buttons .= Html::element( 'input', $attrs ) . "\n";
}
- $html = Html::rawElement( 'div',
- [ 'class' => 'mw-htmlform-submit-buttons' ], "\n$buttons" ) . "\n";
+ if ( !$buttons ) {
+ return '';
+ }
- return $html;
+ return Html::rawElement( 'div',
+ [ 'class' => 'mw-htmlform-submit-buttons' ], "\n$buttons" ) . "\n";
}
}