31 $field = parent::loadInputFromParameters( $fieldname, $descriptor, $parent );
32 $field->setShowEmptyLabel(
false );
39'mediawiki.htmlform.codex.styles',
42return parent::getHTML( $submitResult );
54 $attribs = parent::getFormAttributes();
55 $attribs[
'class'] = [
'mw-htmlform',
'mw-htmlform-codex' ];
66 $attributes[
'class'] =
'cdx-field cdx-field--is-fieldset';
67 $legendElement = Html::rawElement(
'legend', [
'class' => [
'cdx-label' ] ], $legend );
68return Html::rawElement(
'fieldset', $attributes,
"$legendElement\n$section" ) .
"\n";
79 $legendText = $this->
msg(
80 $this->mMessagePrefix ?
"{$this->mMessagePrefix}-$key" : $key
84 [
'class' => [
'cdx-label__label__text' ] ],
88 $isOptional = $this->mSections[$key][
'optional'] ??
false;
89 $optionalFlagMarkup =
'';
93 [
'class' => [
'cdx-label__label__optional-flag' ] ],
94 $this->
msg(
'word-separator' )->text() . $this->
msg(
'htmlform-optional-flag' )->text()
98 $descriptionMarkup =
'';
99if ( isset( $this->mSections[$key][
'description-message'] ) ) {
100 $needsParse = $this->mSections[ $key ][
'description-message-parse' ] ??
false;
101 $descriptionMessage = $this->
msg( $this->mSections[ $key ][
'description-message' ] );
102 $descriptionMarkup = Html::rawElement(
104 [
'class' => [
'cdx-label__description' ] ],
105 $needsParse ? $descriptionMessage->parse() : $descriptionMessage->escaped()
107 } elseif ( isset( $this->mSections[$key][
'description'] ) ) {
110 [
'class' => [
'cdx-label__description' ] ],
111 $this->mSections[ $key ][
'description' ]
115return Html::rawElement(
117 [
'class' => [
'cdx-label__label' ] ],
118 $legendTextMarkup . $optionalFlagMarkup
119 ) . $descriptionMarkup;
123protectedfunctionformatSection( array $fieldsHtml, $sectionName, $anyFieldHasLabel ) {
125// Do not generate any wrappers for empty sections. Sections may be empty if they only 126// have subsections, but no fields. A legend will still be added in 127// wrapFieldSetSection(). 131 $html = implode(
'', $fieldsHtml );
135'id' => Sanitizer::escapeIdForAttribute( $sectionName ),
136'class' => [
'cdx-field__control' ]
139return Html::rawElement(
'div', $attribs, $html );
153if ( $this->mShowSubmit ) {
155// Define flag classes for the submit button 157 $submitClasses = [
'mw-htmlform-submit',
'cdx-button' ];
163if ( $this->mSubmitTooltip !==
null ) {
164 $submitTooltip += Linker::tooltipAndAccesskeyAttribs( $this->mSubmitTooltip );
170'name' => $submitName,
172'class' => $submitClasses,
173'formnovalidate' =>
false,
178 htmlspecialchars( $submitButtonLabel ),
181 $buttons[] = $button;
184// The reset button is unused and will be removed from HTMLForm (T361032). 186if ( $this->mShowCancel ) {
190'cdx-button--fake-button',
191'cdx-button--fake-button--enabled',
195'class' => $buttonClasses,
199'a', $attr, $this->
msg(
'cancel' )->text()
201 $buttons[] = $cancelButton;
204foreach ( $this->mButtons as $button ) {
207'name' => $button[
'name'],
208'value' => $button[
'value']
211if ( isset( $button[
'label-message'] ) ) {
212 $label = $this->
getMessage( $button[
'label-message'] )->parse();
213 } elseif ( isset( $button[
'label'] ) ) {
214 $label = htmlspecialchars( $button[
'label'] );
215 } elseif ( isset( $button[
'label-raw'] ) ) {
216 $label = $button[
'label-raw'];
218 $label = htmlspecialchars( $button[
'value'] );
221// @phan-suppress-next-line PhanTypePossiblyInvalidDimOffset Always set in self::addButton 222if ( $button[
'attribs'] ) {
223// @phan-suppress-next-line PhanTypePossiblyInvalidDimOffset Always set in self::addButton 224 $attrs += $button[
'attribs'];
227if ( isset( $button[
'id'] ) ) {
228 $attrs[
'id'] = $button[
'id'];
231 Html::addClass( $attrs[
'class'],
'cdx-button' );
233 $buttons[] = Html::rawElement(
'button', $attrs, $label ) .
"\n";
240return Html::rawElement(
242 [
'class' =>
'mw-htmlform-submit-buttons' ],
243 implode(
"\n", $buttons )
249class_alias( CodexHTMLForm::class,
'CodexHTMLForm' );
msg( $key,... $params)
Get a Message object with context set Parameters are the same as wfMessage()
wrapForm( $html)
Wrap the form innards in an actual "<form>" element.to override string|\OOUI\Tag Wrapped HTML.
getHTML( $submitResult)
Returns the raw HTML generated by the form.to overridestring HTML
static loadInputFromParameters( $fieldname, $descriptor, ?HTMLForm $parent=null)
Initialise a new Object for the field.to overrideNot passing (or passing null) for $parent is depreca...
getButtons()
Get the submit and cancel buttons.
formatSection(array $fieldsHtml, $sectionName, $anyFieldHasLabel)
Put a form section together from the individual fields' HTML, merging it and wrapping....
getLegend( $key)
Note that this method returns HTML, while the parent method specifies that it should return a plain s...
getFormAttributes()
Get HTML attributes for the <form> tag.to override array
formatField(HTMLFormField $field, $value)
Generate the HTML for an individual field in the current display format.1.41 to override string|Strin...
wrapFieldSetSection( $legend, $section, $attributes, $isRoot)
Wraps the given $section into a user-visible fieldset.to overridestring The fieldset's Html
Adds a generic button inline to the form.
static buildCodexComponent( $flags, $buttonLabel, $attribs)
Build the markup of the Codex component.
The parent class to generate form fields.
getCodex( $value)
Get the Codex version of the div.
Object handling generic submission, CSRF protection, layout and other logic for UI forms in a reusabl...
getMessage( $value)
Turns a *-message parameter (which could be a MessageSpecifier, or a message name,...
getSubmitText()
Get the text for the submit button, either customised or a default.
This class is a collection of static functions that serve two purposes:
Some internal bits split of from Skin.php.
HTML sanitizer for MediaWiki.
element(SerializerNode $parent, SerializerNode $node, $contents)