44 $field = parent::loadInputFromParameters( $fieldname, $descriptor, $parent );
45 $field->setShowEmptyLabel(
false );
49 public function getHTML( $submitResult ) {
51 'mediawiki.htmlform.codex.styles',
54 return parent::getHTML( $submitResult );
65 $attribs = parent::getFormAttributes();
66 $attribs[
'class'] = [
'mw-htmlform',
'mw-htmlform-codex' ];
75 $attributes[
'class'] =
'cdx-field';
76 $legendElement = Html::rawElement(
'legend', [
'class' => [
'cdx-label' ] ], $legend );
77 return Html::rawElement(
'fieldset', $attributes,
"$legendElement\n$section" ) .
"\n";
88 $legendText = $this->
msg(
89 $this->mMessagePrefix ?
"{$this->mMessagePrefix}-$key" : $key
93 [
'class' => [
'cdx-label__label__text' ] ],
97 $isOptional = $this->mSections[$key][
'optional'] ??
false;
98 $optionalFlagMarkup =
'';
102 [
'class' => [
'cdx-label__label__optional-flag' ] ],
103 $this->
msg(
'word-separator' )->text() . $this->
msg(
'htmlform-optional-flag' )->text()
107 $descriptionMarkup =
'';
108 if ( isset( $this->mSections[$key][
'description-message'] ) ) {
109 $needsParse = $this->mSections[ $key ][
'description-message-parse' ] ??
false;
110 $descriptionMessage = $this->
msg( $this->mSections[ $key ][
'description-message' ] );
111 $descriptionMarkup = Html::rawElement(
113 [
'class' => [
'cdx-label__description' ] ],
114 $needsParse ? $descriptionMessage->parse() : $descriptionMessage->escaped()
116 } elseif ( isset( $this->mSections[$key][
'description'] ) ) {
119 [
'class' => [
'cdx-label__description' ] ],
120 $this->mSections[ $key ][
'description' ]
124 return Html::rawElement(
126 [
'class' => [
'cdx-label__label' ] ],
127 $legendTextMarkup . $optionalFlagMarkup
128 ) . $descriptionMarkup;
131 protected function formatSection( array $fieldsHtml, $sectionName, $anyFieldHasLabel ) {
132 if ( !$fieldsHtml ) {
139 $html = implode(
'', $fieldsHtml );
141 if ( $sectionName ) {
143 'id' => Sanitizer::escapeIdForAttribute( $sectionName ),
144 'class' => [
'cdx-field__control' ]
147 return Html::rawElement(
'div', $attribs, $html );
161 if ( $this->mShowSubmit ) {
165 $submitClasses = [
'mw-htmlform-submit',
'cdx-button' ];
171 if ( $this->mSubmitTooltip !==
null ) {
172 $submitTooltip += Linker::tooltipAndAccesskeyAttribs( $this->mSubmitTooltip );
178 'name' => $submitName,
180 'class' => $submitClasses,
181 'formnovalidate' =>
false,
189 $buttons[] = $button;
194 if ( $this->mShowCancel ) {
198 'cdx-button--fake-button',
199 'cdx-button--fake-button--enabled',
203 'class' => $buttonClasses,
207 'a', $attr, $this->
msg(
'cancel' )->text()
209 $buttons[] = $cancelButton;
212 foreach ( $this->mButtons as $button ) {
215 'name' => $button[
'name'],
216 'value' => $button[
'value']
219 if ( isset( $button[
'label-message'] ) ) {
220 $label = $this->
getMessage( $button[
'label-message'] )->parse();
221 } elseif ( isset( $button[
'label'] ) ) {
222 $label = htmlspecialchars( $button[
'label'] );
223 } elseif ( isset( $button[
'label-raw'] ) ) {
224 $label = $button[
'label-raw'];
226 $label = htmlspecialchars( $button[
'value'] );
230 if ( $button[
'attribs'] ) {
232 $attrs += $button[
'attribs'];
235 if ( isset( $button[
'id'] ) ) {
236 $attrs[
'id'] = $button[
'id'];
239 if ( isset( $attrs[
'class'] ) ) {
242 $attrs[
'class'] = (array)( $attrs[
'class'] ?? [] );
245 $attrs[
'class'][] =
'cdx-button';
247 $buttons[] = Html::rawElement(
'button', $attrs, $label ) .
"\n";
254 return Html::rawElement(
256 [
'class' =>
'mw-htmlform-submit-buttons' ],
257 implode(
"\n", $buttons )
263class_alias( CodexHTMLForm::class,
'CodexHTMLForm' );
msg( $key,... $params)
Get a Message object with context set Parameters are the same as wfMessage()