47 $info[
'nodata'] =
true;
51 parent::__construct( $info );
53 if ( isset( $info[
'flags'] ) ) {
54 $this->mFlags = $info[
'flags'];
57 if ( isset( $info[
'formnovalidate'] ) ) {
58 $this->mFormnovalidate = $info[
'formnovalidate'];
61 # Generate the label from a message, if possible
62 if ( isset( $info[
'buttonlabel-message'] ) ) {
63 $this->buttonLabel = $this->
getMessage( $info[
'buttonlabel-message'] )->parse();
64 } elseif ( isset( $info[
'buttonlabel'] ) ) {
65 if ( $info[
'buttonlabel'] ===
' ' || $info[
'buttonlabel'] ===
"\u{00A0}" ) {
67 $this->buttonLabel =
"\u{00A0}";
69 $this->buttonLabel = htmlspecialchars( $info[
'buttonlabel'] );
71 } elseif ( isset( $info[
'buttonlabel-raw'] ) ) {
72 $this->buttonLabel = $info[
'buttonlabel-raw'];
78 $prefix =
'mw-htmlform-';
82 $flags .=
' ' . $prefix .
'button';
84 foreach ( $this->mFlags as $flag ) {
85 $flags .=
' ' . $prefix . $flag;
88 'class' =>
'mw-htmlform-submit ' . $this->mClass . $flags,
96 return Html::rawElement(
'button', $attr,
97 $this->buttonLabel ?: htmlspecialchars( $this->
getDefault() ) );
107 return new \OOUI\ButtonInputWidget( [
108 'name' => $this->mName,
110 'label' => $this->buttonLabel
111 ?
new \OOUI\HtmlSnippet( $this->buttonLabel )
117 ] + \OOUI\Element::configFromHtmlAttributes(
125 $buttonClasses = [
'mw-htmlform-submit',
'cdx-button',
$this->mClass ];
127 'class' => $buttonClasses,
135 return static::buildCodexComponent(
157 'progressive' =>
'cdx-button--action-progressive',
158 'destructive' =>
'cdx-button--action-destructive',
159 'primary' =>
'cdx-button--weight-primary',
160 'quiet' =>
'cdx-button--weight-quiet',
163 foreach ( $flags as $flag ) {
164 if ( isset( $flagClassMap[$flag] ) ) {
165 $flagClasses[] = $flagClassMap[$flag];
169 $buttonClassesAndFlags = array_merge( $attribs[
'class' ], $flagClasses );
170 $attribs[
'class'] = $buttonClassesAndFlags;
172 $buttonHtml = Html::rawElement(
202class_alias( HTMLButtonField::class,
'HTMLButtonField' );