43 $field = parent::loadInputFromParameters( $fieldname, $descriptor, $parent );
44 $field->setShowEmptyLabel(
false );
48 public function getHTML( $submitResult ) {
50 'mediawiki.htmlform.codex.styles',
53 return parent::getHTML( $submitResult );
64 $attribs = parent::getFormAttributes();
65 $attribs[
'class'] = [
'mw-htmlform',
'mw-htmlform-codex' ];
74 $attributes[
'class'] =
'cdx-field';
75 $legendElement = Html::rawElement(
'legend', [
'class' => [
'cdx-label' ] ], $legend );
76 return Html::rawElement(
'fieldset', $attributes,
"$legendElement\n$section" ) .
"\n";
87 $legendText = $this->
msg(
88 $this->mMessagePrefix ?
"{$this->mMessagePrefix}-$key" : $key
92 [
'class' => [
'cdx-label__label__text' ] ],
96 $isOptional = $this->mSections[$key][
'optional'] ??
false;
97 $optionalFlagMarkup =
'';
101 [
'class' => [
'cdx-label__label__optional-flag' ] ],
102 $this->
msg(
'word-separator' )->text() . $this->
msg(
'htmlform-optional-flag' )->text()
106 $descriptionMarkup =
'';
107 if ( isset( $this->mSections[$key][
'description-message'] ) ) {
108 $needsParse = $this->mSections[ $key ][
'description-message-parse' ] ??
false;
109 $descriptionMessage = $this->
msg( $this->mSections[ $key ][
'description-message' ] );
110 $descriptionMarkup = Html::rawElement(
112 [
'class' => [
'cdx-label__description' ] ],
113 $needsParse ? $descriptionMessage->parse() : $descriptionMessage->escaped()
115 } elseif ( isset( $this->mSections[$key][
'description'] ) ) {
118 [
'class' => [
'cdx-label__description' ] ],
119 $this->mSections[ $key ][
'description' ]
123 return Html::rawElement(
125 [
'class' => [
'cdx-label__label' ] ],
126 $legendTextMarkup . $optionalFlagMarkup
127 ) . $descriptionMarkup;
130 protected function formatSection( array $fieldsHtml, $sectionName, $anyFieldHasLabel ) {
131 if ( !$fieldsHtml ) {
138 $html = implode(
'', $fieldsHtml );
140 if ( $sectionName ) {
142 'id' => Sanitizer::escapeIdForAttribute( $sectionName ),
143 'class' => [
'cdx-field__control' ]
146 return Html::rawElement(
'div', $attribs, $html );
160 if ( $this->mShowSubmit ) {
164 $submitClasses = [
'mw-htmlform-submit',
'cdx-button' ];
170 if ( isset( $this->mSubmitTooltip ) ) {
171 $submitTooltip += Linker::tooltipAndAccesskeyAttribs( $this->mSubmitTooltip );
177 'name' => $submitName,
179 'class' => $submitClasses,
180 'formnovalidate' =>
false,
188 $buttons[] = $button;
193 if ( $this->mShowCancel ) {
197 'cdx-button--fake-button',
198 'cdx-button--fake-button--enabled',
202 'class' => $buttonClasses,
206 'a', $attr, $this->
msg(
'cancel' )->text()
208 $buttons[] = $cancelButton;
211 foreach ( $this->mButtons as $button ) {
214 'name' => $button[
'name'],
215 'value' => $button[
'value']
218 if ( isset( $button[
'label-message'] ) ) {
219 $label = $this->
getMessage( $button[
'label-message'] )->parse();
220 } elseif ( isset( $button[
'label'] ) ) {
221 $label = htmlspecialchars( $button[
'label'] );
222 } elseif ( isset( $button[
'label-raw'] ) ) {
223 $label = $button[
'label-raw'];
225 $label = htmlspecialchars( $button[
'value'] );
229 if ( $button[
'attribs'] ) {
231 $attrs += $button[
'attribs'];
234 if ( isset( $button[
'id'] ) ) {
235 $attrs[
'id'] = $button[
'id'];
238 if ( isset( $attrs[
'class'] ) ) {
241 $attrs[
'class'] = (array)( $attrs[
'class'] ?? [] );
244 $attrs[
'class'][] =
'cdx-button';
246 $buttons[] = Html::rawElement(
'button', $attrs, $label ) .
"\n";
253 return Html::rawElement(
255 [
'class' =>
'mw-htmlform-submit-buttons' ],
256 implode(
"\n", $buttons )
262class_alias( CodexHTMLForm::class,
'CodexHTMLForm' );
msg( $key,... $params)
Get a Message object with context set Parameters are the same as wfMessage()