44 $info[
'nodata'] =
true;
48 parent::__construct( $info );
50 if ( isset( $info[
'flags'] ) ) {
51 $this->mFlags = $info[
'flags'];
54 if ( isset( $info[
'formnovalidate'] ) ) {
55 $this->mFormnovalidate = $info[
'formnovalidate'];
58 # Generate the label from a message, if possible
59 if ( isset( $info[
'buttonlabel-message'] ) ) {
60 $this->buttonLabel = $this->
getMessage( $info[
'buttonlabel-message'] )->parse();
61 } elseif ( isset( $info[
'buttonlabel'] ) ) {
62 if ( $info[
'buttonlabel'] ===
' ' || $info[
'buttonlabel'] ===
"\u{00A0}" ) {
64 $this->buttonLabel =
"\u{00A0}";
66 $this->buttonLabel = htmlspecialchars( $info[
'buttonlabel'] );
68 } elseif ( isset( $info[
'buttonlabel-raw'] ) ) {
69 $this->buttonLabel = $info[
'buttonlabel-raw'];
75 $prefix =
'mw-htmlform-';
79 $flags .=
' ' . $prefix .
'button';
81 foreach ( $this->mFlags as $flag ) {
82 $flags .=
' ' . $prefix . $flag;
85 'class' =>
'mw-htmlform-submit ' . $this->mClass . $flags,
93 return Html::rawElement(
'button', $attr,
94 $this->buttonLabel ?: htmlspecialchars( $this->
getDefault() ) );
104 return new \OOUI\ButtonInputWidget( [
105 'name' => $this->mName,
107 'label' => $this->buttonLabel
108 ?
new \OOUI\HtmlSnippet( $this->buttonLabel )
114 ] + \OOUI\Element::configFromHtmlAttributes(
122 'progressive' =>
'cdx-button--action-progressive',
123 'destructive' =>
'cdx-button--action-destructive',
124 'primary' =>
'cdx-button--weight-primary',
125 'quiet' =>
'cdx-button--weight-quiet',
128 foreach ( $this->mFlags as $flag ) {
129 if ( isset( $flagClassMap[$flag] ) ) {
130 $flags[] = $flagClassMap[$flag];
134 $buttonClasses = [
'mw-htmlform-submit',
'cdx-button',
$this->mClass ];
135 $buttonClassesAndFlags = array_merge( $buttonClasses, $flags );
137 'class' => $buttonClassesAndFlags,
145 return Html::rawElement(
'button', $attr,
146 $this->buttonLabel ?: htmlspecialchars( $this->
getDefault() ) );
172class_alias( HTMLButtonField::class,
'HTMLButtonField' );