MediaWiki REL1_34
|
Object handling generic submission, CSRF protection, layout and other logic for UI forms in a reusable manner. More...
Public Member Functions | |
__construct ( $descriptor, $context=null, $messagePrefix='') | |
Build a new HTMLForm from an array of field attributes. | |
addButton ( $data) | |
Add a button to the form. | |
addFields ( $descriptor) | |
Add fields to the form. | |
addFooterText ( $msg, $section=null) | |
Add footer text, inside the form. | |
addHeaderText ( $msg, $section=null) | |
Add HTML to the header, inside the form. | |
addHiddenField ( $name, $value, array $attribs=[]) | |
Add a hidden field to the output. | |
addHiddenFields (array $fields) | |
Add an array of hidden fields to the output. | |
addPostText ( $msg) | |
Add text to the end of the display. | |
addPreText ( $msg) | |
Add HTML to introductory message. | |
displayForm ( $submitResult) | |
Display the form (sending to the context's OutputPage object), with an appropriate error message or stack of messages, and any validation errors, etc. | |
displaySection ( $fields, $sectionName='', $fieldsetIDPrefix='', &$hasUserVisibleFields=false) | |
filterDataForSubmit ( $data) | |
Overload this if you want to apply special filtration routines to the form as a whole, after it's submitted but before it's processed. | |
formatErrors ( $errors) | |
Format a stack of error messages into a single HTML string. | |
getAction () | |
Get the value for the action attribute of the form. | |
getBody () | |
Get the whole body of the form. | |
getButtons () | |
Get the submit and (potentially) reset buttons. | |
getDisplayFormat () | |
Getter for displayFormat. | |
getErrorsOrWarnings ( $elements, $elementsType) | |
Returns a formatted list of errors or warnings from the given elements. | |
getField ( $fieldname) | |
getFooterText ( $section=null) | |
Get footer text. | |
getHeaderText ( $section=null) | |
Get header text. | |
getHiddenFields () | |
Get the hidden fields that should go inside the form. | |
getHTML ( $submitResult) | |
Returns the raw HTML generated by the form. | |
getLegend ( $key) | |
Get a string to go in the "<legend>" of a section fieldset. | |
getMethod () | |
getPreText () | |
Get the introductory message HTML. | |
getSubmitText () | |
Get the text for the submit button, either customised or a default. | |
getTitle () | |
Get the title. | |
hasField ( $fieldname) | |
loadData () | |
Construct the form fields from the Descriptor array. | |
needsJSForHtml5FormValidation () | |
Whether this form, with its current fields, requires the user agent to have JavaScript enabled for the client-side HTML5 form validation to work correctly. | |
prepareForm () | |
Prepare form for submission. | |
setAction ( $action) | |
Set the value for the action attribute of the form. | |
setAutocomplete ( $autocomplete) | |
Set the value for the autocomplete attribute of the form. | |
setCancelTarget ( $target) | |
Sets the target where the user is redirected to after clicking cancel. | |
setCollapsibleOptions ( $collapsedByDefault=false) | |
Enable collapsible mode, and set whether the form is collapsed by default. | |
setDisplayFormat ( $format) | |
Set format in which to display the form. | |
setFooterText ( $msg, $section=null) | |
Set footer text, inside the form. | |
setFormIdentifier ( $ident) | |
Set an internal identifier for this form. | |
setHeaderText ( $msg, $section=null) | |
Set header text, inside the form. | |
setId ( $id) | |
setIntro ( $msg) | |
Set the introductory message, overwriting any existing message. | |
setMessagePrefix ( $p) | |
Set the prefix for various default messages. | |
setMethod ( $method='post') | |
Set the method used to submit the form. | |
setName ( $name) | |
setPostText ( $msg) | |
Set text at the end of the display. | |
setPreText ( $msg) | |
Set the introductory message HTML, overwriting any existing message. | |
setSubmitCallback ( $cb) | |
Set a callback to a function to do something with the form once it's been successfully validated. | |
setSubmitDestructive () | |
Identify that the submit button in the form has a destructive action. | |
setSubmitID ( $t) | |
Set the id for the submit button. | |
setSubmitName ( $name) | |
setSubmitText ( $t) | |
Set the text for the submit button. | |
setSubmitTextMsg ( $msg) | |
Set the text for the submit button to a message. | |
setSubmitTooltip ( $name) | |
setTableId ( $id) | |
Set the id of the \<table\> or outermost \<div\> element. | |
setTitle ( $t) | |
Set the title for form submission. | |
setTokenSalt ( $salt) | |
Set the salt for the edit token. | |
setValidationErrorMessage ( $msg) | |
Set a message to display on a validation error. | |
setWrapperAttributes ( $attributes) | |
For internal use only. | |
setWrapperLegend ( $legend) | |
Prompt the whole form to be wrapped in a "<fieldset>", with this text as its "<legend>" element. | |
setWrapperLegendMsg ( $msg) | |
Prompt the whole form to be wrapped in a "<fieldset>", with this message as its "<legend>" element. | |
show () | |
The here's-one-I-made-earlier option: do the submission if posted, or display the form with or without funky validation errors. | |
showAlways () | |
Same as self::show with the difference, that the form will be added to the output, no matter, if the validation was good or not. | |
showCancel ( $show=true) | |
Show a cancel button (or prevent it). | |
suppressDefaultSubmit ( $suppressSubmit=true) | |
Stop a default submit button being shown for this form. | |
suppressReset ( $suppressReset=true) | |
Stop a reset button being shown for this form. | |
tryAuthorizedSubmit () | |
Try submitting, with edit token check first. | |
trySubmit () | |
Validate all the fields, and call the submission callback function if everything is kosher. | |
wasSubmitted () | |
Test whether the form was considered to have been submitted or not, i.e. | |
wrapForm ( $html) | |
Wrap the form innards in an actual "<form>" element. | |
Public Member Functions inherited from ContextSource | |
canUseWikiPage () | |
Check whether a WikiPage object can be get with getWikiPage(). | |
exportSession () | |
Export the resolved user IP, HTTP headers, user ID, and session ID. | |
getConfig () | |
getContext () | |
Get the base IContextSource object. | |
getLanguage () | |
getOutput () | |
getRequest () | |
getSkin () | |
getStats () | |
getTiming () | |
getUser () | |
getWikiPage () | |
Get the WikiPage object. | |
msg ( $key,... $params) | |
Get a Message object with context set Parameters are the same as wfMessage() | |
setContext (IContextSource $context) | |
Static Public Member Functions | |
static | factory ( $displayFormat,... $arguments) |
Construct a HTMLForm object for given display type. | |
static | getClassFromDescriptor ( $fieldname, &$descriptor) |
Get the HTMLFormField subclass for this descriptor. | |
static | loadInputFromParameters ( $fieldname, $descriptor, HTMLForm $parent=null) |
Initialise a new Object for the field. | |
Public Attributes | |
$mFieldData | |
Static Public Attributes | |
static | $typeMappings |
Protected Member Functions | |
formatSection (array $fieldsHtml, $sectionName, $anyFieldHasLabel) | |
Put a form section together from the individual fields' HTML, merging it and wrapping. | |
getFormAttributes () | |
Get HTML attributes for the <form> tag. | |
getMessage ( $value) | |
Turns a *-message parameter (which could be a MessageSpecifier, or a message name, or a name + parameters array) into a Message. | |
wrapFieldSetSection ( $legend, $section, $attributes, $isRoot) | |
Wraps the given $section into an user-visible fieldset. | |
Protected Attributes | |
array | $availableDisplayFormats |
Available formats in which to display the form. | |
array | $availableSubclassDisplayFormats |
Available formats in which to display the form. | |
string | $displayFormat = 'table' |
Format in which to display form. | |
bool string | $mAction = false |
Form action URL. | |
string null | $mAutocomplete = null |
Form attribute autocomplete. | |
array[] | $mButtons = [] |
-var array<array{name:string,value:string,label-message?:string,label?:string,label-raw?:string,id?:string,attribs?:array,flags?:string|string[],framed?:bool}> | |
$mCancelTarget | |
bool | $mCollapsed = false |
Whether the form is collapsed by default. | |
bool | $mCollapsible = false |
Whether the form can be collapsed. | |
$mFieldTree = [] | |
HTMLFormField[] | $mFlatFields = [] |
$mFooter = '' | |
$mFormIdentifier | |
$mHeader = '' | |
$mHiddenFields = [] | |
$mId | |
$mMessagePrefix | |
$mMethod = 'post' | |
$mName | |
$mPost = '' | |
$mPre = '' | |
$mSectionFooters = [] | |
$mSectionHeaders = [] | |
$mShowCancel = false | |
$mShowReset = false | |
$mShowSubmit = true | |
$mSubmitCallback | |
string[] | $mSubmitFlags = [ 'primary', 'progressive' ] |
$mSubmitID | |
$mSubmitName | |
$mSubmitText | |
$mSubmitTooltip | |
$mSubSectionBeforeFields = true | |
If true, sections that contain both fields and subsections will render their subsections before their fields. | |
$mTableId = '' | |
$mTitle | |
string array | $mTokenSalt = '' |
Salt for the edit token. | |
$mUseMultipart = false | |
$mValidationErrorMessage | |
$mWasSubmitted = false | |
$mWrapperAttributes = [] | |
$mWrapperLegend = false | |
Object handling generic submission, CSRF protection, layout and other logic for UI forms in a reusable manner.
In order to generate the form, the HTMLForm object takes an array structure detailing the form fields available. Each element of the array is a basic property-list, including the type of field, the label it is to be given in the form, callbacks for validation and 'filtering', and other pertinent information.
Field types are implemented as subclasses of the generic HTMLFormField object, and typically implement at least getInputHTML, which generates the HTML for the input field to be placed in the table.
You can find extensive documentation on the www.mediawiki.org wiki:
The constructor input is an associative array of $fieldname => $info, where $info is an Associative Array with any of the following:
'class' – the subclass of HTMLFormField that will be used to create the object. NOT the CSS class! 'type' – roughly translates into the <select> type attribute. if 'class' is not specified, this is used as a map through HTMLForm::$typeMappings to get the class name. 'default' – default value when the form is displayed 'nodata' – if set (to any value, which casts to true), the data for this field will not be loaded from the actual request. Instead, always the default data is set as the value of this field. 'id' – HTML id attribute 'cssclass' – CSS class 'csshelpclass' – CSS class used to style help text 'dir' – Direction of the element. 'options' – associative array mapping raw text labels to values. Some field types support multi-level arrays. Overwrites 'options-message'. 'options-messages' – associative array mapping message keys to values. Some field types support multi-level arrays. Overwrites 'options' and 'options-message'. 'options-message' – message key or object to be parsed to extract the list of options (like 'ipbreason-dropdown'). 'label-message' – message key or object for a message to use as the label. can be an array of msg key and then parameters to the message. 'label' – alternatively, a raw text message. Overridden by label-message 'help' – message text for a message to use as a help text. 'help-message' – message key or object for a message to use as a help text. can be an array of msg key and then parameters to the message. Overwrites 'help-messages' and 'help'. 'help-messages' – array of message keys/objects. As above, each item can be an array of msg key and then parameters. Overwrites 'help'. 'help-inline' – Whether help text (defined using options above) will be shown inline after the input field, rather than in a popup. Defaults to true. Only used by OOUI form fields. 'required' – passed through to the object, indicating that it is a required field. 'size' – the length of text fields 'filter-callback' – a function name to give you the chance to massage the inputted value before it's processed.
Since 1.20, you can chain mutators to ease the form generation:
Definition at line 131 of file HTMLForm.php.
HTMLForm::__construct | ( | $descriptor, | |
$context = null, | |||
$messagePrefix = '' ) |
Build a new HTMLForm from an array of field attributes.
array | $descriptor | Array of Field constructs, as described in the class documentation |
IContextSource | null | $context | Available since 1.18, will become compulsory in 1.18. Obviates the need to call $form->setTitle() |
string | $messagePrefix | A prefix to go in front of default messages |
Reimplemented in OOUIHTMLForm.
Definition at line 325 of file HTMLForm.php.
References $context, addFields(), ContextSource\getConfig(), and ContextSource\setContext().
HTMLForm::addButton | ( | $data | ) |
Add a button to the form.
array | $data | Data to define the button:
|
-param array{name:string,value:string,label-message?:string,label?:string,label-raw?:string,id?:string,attribs?:array,flags?:string|string[],framed?:bool} $data
Definition at line 991 of file HTMLForm.php.
References $args.
Referenced by McrUndoAction\alterForm(), and SpecialBotPasswords\alterForm().
HTMLForm::addFields | ( | $descriptor | ) |
Add fields to the form.
array | $descriptor | Array of Field constructs, as described in the class documentation |
Definition at line 360 of file HTMLForm.php.
HTMLForm::addFooterText | ( | $msg, | |
$section = null ) |
Add footer text, inside the form.
string | $msg | Complete text of message to display |
string | null | $section | The section to add the footer text to |
Definition at line 857 of file HTMLForm.php.
Referenced by UploadForm\__construct().
HTMLForm::addHeaderText | ( | $msg, | |
$section = null ) |
Add HTML to the header, inside the form.
string | $msg | Additional HTML to display in header |
string | null | $section | The section to add the header to |
Definition at line 802 of file HTMLForm.php.
Referenced by SpecialBlock\alterForm(), SpecialChangeEmail\alterForm(), SpecialUserLogout\alterForm(), and UploadForm\getDescriptionSection().
HTMLForm::addHiddenField | ( | $name, | |
$value, | |||
array | $attribs = [] ) |
Add a hidden field to the output.
string | $name | Field name. This will be used exactly as entered |
string | $value | Field value |
array | $attribs |
Definition at line 939 of file HTMLForm.php.
Referenced by McrRestoreAction\addStatePropagationFields(), McrUndoAction\addStatePropagationFields(), MarkpatrolledAction\alterForm(), RevertAction\alterForm(), and RollbackAction\alterForm().
HTMLForm::addHiddenFields | ( | array | $fields | ) |
Add an array of hidden fields to the output.
array | $fields | Associative array of fields to add; mapping names to their values |
Definition at line 956 of file HTMLForm.php.
Referenced by SpecialChangeEmail\alterForm(), SpecialPasswordReset\alterForm(), and SpecialUserLogout\alterForm().
HTMLForm::addPostText | ( | $msg | ) |
Add text to the end of the display.
string | $msg | Complete text of message to display |
Definition at line 911 of file HTMLForm.php.
HTMLForm::addPreText | ( | $msg | ) |
Add HTML to introductory message.
string | $msg | Complete HTML of message to display |
Definition at line 777 of file HTMLForm.php.
Referenced by SpecialBotPasswords\alterForm().
HTMLForm::displayForm | ( | $submitResult | ) |
Display the form (sending to the context's OutputPage object), with an appropriate error message or stack of messages, and any validation errors, etc.
bool | string | array | Status | $submitResult | Output from HTMLForm::trySubmit() |
Reimplemented in MediaWiki\Extension\OATHAuth\HTMLForm\OATHAuthOOUIHTMLForm.
Definition at line 1050 of file HTMLForm.php.
References getHTML(), and ContextSource\getOutput().
Referenced by show(), and showAlways().
HTMLForm::displaySection | ( | $fields, | |
$sectionName = '', | |||
$fieldsetIDPrefix = '', | |||
& | $hasUserVisibleFields = false ) |
array[] | HTMLFormField[] | $fields | Array of fields (either arrays or objects). |
string | $sectionName | ID attribute of the "<table>" tag for this section, ignored if empty. |
string | $fieldsetIDPrefix | ID prefix for the "<fieldset>" tag of each subsection, ignored if empty. |
bool | &$hasUserVisibleFields | Whether the section had user-visible fields. |
LogicException | When called on uninitialized field data, e.g. When HTMLForm::displayForm was called without calling HTMLForm::prepareForm first. |
Reimplemented in EditWatchlistNormalHTMLForm.
Definition at line 1671 of file HTMLForm.php.
References displaySection(), formatSection(), getDisplayFormat(), getFooterText(), getHeaderText(), getLegend(), and wrapFieldSetSection().
Referenced by displaySection(), getBody(), and PreferencesFormOOUI\getBody().
|
static |
Construct a HTMLForm object for given display type.
May return a HTMLForm subclass.
string | $displayFormat | |
mixed | ...$arguments Additional arguments to pass to the constructor. |
Definition at line 303 of file HTMLForm.php.
HTMLForm::filterDataForSubmit | ( | $data | ) |
Overload this if you want to apply special filtration routines to the form as a whole, after it's submitted but before it's processed.
array | $data |
Reimplemented in PreferencesFormOOUI.
Definition at line 1851 of file HTMLForm.php.
Referenced by trySubmit().
HTMLForm::formatErrors | ( | $errors | ) |
Format a stack of error messages into a single HTML string.
array | $errors | Array of message keys/values |
Definition at line 1339 of file HTMLForm.php.
References getMessage().
Referenced by SpecialBlock\alterForm(), and getErrorsOrWarnings().
|
protected |
Put a form section together from the individual fields' HTML, merging it and wrapping.
array | $fieldsHtml | |
string | $sectionName | |
bool | $anyFieldHasLabel |
Reimplemented in OOUIHTMLForm.
Definition at line 1764 of file HTMLForm.php.
References getDisplayFormat().
Referenced by displaySection().
HTMLForm::getAction | ( | ) |
Get the value for the action attribute of the form.
Definition at line 1890 of file HTMLForm.php.
References ContextSource\getConfig(), getMethod(), getTitle(), and wfScript().
Referenced by getFormAttributes().
HTMLForm::getBody | ( | ) |
Get the whole body of the form.
Reimplemented in OOUIHTMLForm, and PreferencesFormOOUI.
Definition at line 1294 of file HTMLForm.php.
References displaySection().
Referenced by getHTML().
HTMLForm::getButtons | ( | ) |
Get the submit and (potentially) reset buttons.
Reimplemented in OOUIHTMLForm, VFormHTMLForm, and PreferencesFormOOUI.
Definition at line 1185 of file HTMLForm.php.
References ContextSource\getConfig(), getMessage(), ContextSource\getRequest(), getSubmitText(), ContextSource\msg(), and Linker\tooltipAndAccesskeyAttribs().
Referenced by getHTML().
|
static |
Get the HTMLFormField subclass for this descriptor.
The descriptor can be passed either 'class' which is the name of a HTMLFormField subclass, or a shorter 'type' which is an alias. This makes sure the 'class' is always set, and also is returned by this function for ease.
string | $fieldname | Name of the field |
array | &$descriptor | Input Descriptor, as described in the class documentation |
MWException |
Definition at line 479 of file HTMLForm.php.
HTMLForm::getDisplayFormat | ( | ) |
Getter for displayFormat.
Definition at line 458 of file HTMLForm.php.
Referenced by displaySection(), formatSection(), and HTMLCheckField\getLabel().
HTMLForm::getErrorsOrWarnings | ( | $elements, | |
$elementsType ) |
Returns a formatted list of errors or warnings from the given elements.
string | array | Status | $elements | The set of errors/warnings to process. |
string | $elementsType | Should warnings or errors be returned. This is meant for Status objects, all other valid types are always considered as errors. |
Reimplemented in OOUIHTMLForm.
Definition at line 1306 of file HTMLForm.php.
References formatErrors(), and ContextSource\getOutput().
Referenced by getHTML().
HTMLForm::getField | ( | $fieldname | ) |
string | $fieldname |
DomainException | on invalid field name |
Definition at line 406 of file HTMLForm.php.
References hasField().
HTMLForm::getFooterText | ( | $section = null | ) |
Get footer text.
string | null | $section | The section to get the footer text for |
Definition at line 896 of file HTMLForm.php.
Referenced by displaySection(), PreferencesFormOOUI\getBody(), and getHTML().
|
protected |
Get HTML attributes for the <form>
tag.
Reimplemented in VFormHTMLForm.
Definition at line 1099 of file HTMLForm.php.
References getAction(), getMethod(), and needsJSForHtml5FormValidation().
Referenced by wrapForm(), and OOUIHTMLForm\wrapForm().
HTMLForm::getHeaderText | ( | $section = null | ) |
Get header text.
string | null | $section | The section to get the header text for |
Reimplemented in OOUIHTMLForm.
Definition at line 841 of file HTMLForm.php.
Referenced by displaySection(), and getHTML().
HTMLForm::getHiddenFields | ( | ) |
Get the hidden fields that should go inside the form.
Definition at line 1151 of file HTMLForm.php.
References ContextSource\getConfig(), getMethod(), getTitle(), and getUser().
Referenced by getHTML().
HTMLForm::getHTML | ( | $submitResult | ) |
Returns the raw HTML generated by the form.
bool | string | array | Status | $submitResult | Output from HTMLForm::trySubmit() |
Reimplemented in MediaWiki\Extension\OATHAuth\HTMLForm\TOTPEnableForm, and VFormHTMLForm.
Definition at line 1062 of file HTMLForm.php.
References getBody(), getButtons(), getErrorsOrWarnings(), getFooterText(), getHeaderText(), getHiddenFields(), ContextSource\getOutput(), and wrapForm().
Referenced by MediaWiki\Extension\OATHAuth\HTMLForm\OATHAuthOOUIHTMLForm\displayForm(), and displayForm().
HTMLForm::getLegend | ( | $key | ) |
Get a string to go in the "<legend>" of a section fieldset.
Override this if you want something more complicated.
string | $key |
Reimplemented in PreferencesFormOOUI, and EditWatchlistNormalHTMLForm.
Definition at line 1863 of file HTMLForm.php.
References ContextSource\msg().
Referenced by displaySection().
|
protected |
Turns a *-message parameter (which could be a MessageSpecifier, or a message name, or a name + parameters array) into a Message.
mixed | $value |
Definition at line 1931 of file HTMLForm.php.
References Message\newFromSpecifier().
Referenced by formatErrors(), getButtons(), OOUIHTMLForm\getButtons(), and OOUIHTMLForm\getErrorsOrWarnings().
HTMLForm::getMethod | ( | ) |
Definition at line 1638 of file HTMLForm.php.
Referenced by getAction(), getFormAttributes(), getHiddenFields(), and tryAuthorizedSubmit().
HTMLForm::getPreText | ( | ) |
Get the introductory message HTML.
Definition at line 790 of file HTMLForm.php.
HTMLForm::getSubmitText | ( | ) |
Get the text for the submit button, either customised or a default.
Definition at line 1401 of file HTMLForm.php.
References ContextSource\msg().
Referenced by getButtons(), OOUIHTMLForm\getButtons(), and VFormHTMLForm\getButtons().
HTMLForm::getTitle | ( | ) |
Get the title.
Reimplemented from ContextSource.
Definition at line 1616 of file HTMLForm.php.
References $mTitle, and getContext().
Referenced by UploadForm\__construct(), and MediaWiki\Preferences\DefaultPreferencesFactory\submitForm().
HTMLForm::hasField | ( | $fieldname | ) |
string | $fieldname |
Definition at line 397 of file HTMLForm.php.
Referenced by getField().
HTMLForm::loadData | ( | ) |
Construct the form fields from the Descriptor array.
Definition at line 1806 of file HTMLForm.php.
References ContextSource\getRequest().
Referenced by prepareForm().
|
static |
Initialise a new Object for the field.
string | $fieldname | Name of the field |
array | $descriptor | Input Descriptor, as described in the class documentation |
HTMLForm | null | $parent | Parent instance of HTMLForm |
MWException |
Reimplemented in OOUIHTMLForm, and VFormHTMLForm.
Definition at line 508 of file HTMLForm.php.
HTMLForm::needsJSForHtml5FormValidation | ( | ) |
Whether this form, with its current fields, requires the user agent to have JavaScript enabled for the client-side HTML5 form validation to work correctly.
If this function returns true, a 'novalidate' attribute will be added on the <form>
element. It will be removed if the user agent has JavaScript support, in htmlform.js.
Definition at line 1944 of file HTMLForm.php.
Referenced by getFormAttributes().
HTMLForm::prepareForm | ( | ) |
Prepare form for submission.
MWException |
Definition at line 533 of file HTMLForm.php.
References ContextSource\getRequest(), and loadData().
Referenced by show(), and showAlways().
HTMLForm::setAction | ( | $action | ) |
Set the value for the action attribute of the form.
When set to false (which is the default state), the set title is used.
string | bool | $action |
Definition at line 1877 of file HTMLForm.php.
HTMLForm::setAutocomplete | ( | $autocomplete | ) |
Set the value for the autocomplete attribute of the form.
A typical value is "off". When set to null (which is the default state), the attribute get not set.
string | null | $autocomplete |
Definition at line 1919 of file HTMLForm.php.
HTMLForm::setCancelTarget | ( | $target | ) |
Sets the target where the user is redirected to after clicking cancel.
Definition at line 1495 of file HTMLForm.php.
Referenced by McrUndoAction\alterForm().
HTMLForm::setCollapsibleOptions | ( | $collapsedByDefault = false | ) |
Enable collapsible mode, and set whether the form is collapsed by default.
bool | $collapsedByDefault | Whether the form is collapsed by default (optional). |
Definition at line 1089 of file HTMLForm.php.
HTMLForm::setDisplayFormat | ( | $format | ) |
Set format in which to display the form.
string | $format | The name of the format to use, must be one of $this->availableDisplayFormats |
MWException |
Definition at line 423 of file HTMLForm.php.
References ContextSource\getConfig().
HTMLForm::setFooterText | ( | $msg, | |
$section = null ) |
Set footer text, inside the form.
string | $msg | Complete text of message to display |
string | null | $section | The section to add the footer text to |
Definition at line 879 of file HTMLForm.php.
HTMLForm::setFormIdentifier | ( | $ident | ) |
Set an internal identifier for this form.
It will be submitted as a hidden form field, allowing HTMLForm to determine whether the form was submitted (or merely viewed). Setting this serves two purposes:
string | $ident |
Definition at line 1456 of file HTMLForm.php.
HTMLForm::setHeaderText | ( | $msg, | |
$section = null ) |
Set header text, inside the form.
string | $msg | Complete HTML of header to display |
string | null | $section | The section to add the header to |
Definition at line 824 of file HTMLForm.php.
Referenced by SpecialBlock\alterForm(), and SpecialPasswordReset\alterForm().
HTMLForm::setId | ( | $id | ) |
string | $id | DOM id for the form |
Definition at line 1520 of file HTMLForm.php.
Referenced by UploadForm\__construct(), McrUndoAction\alterForm(), SpecialBotPasswords\alterForm(), and SpecialChangeEmail\alterForm().
HTMLForm::setIntro | ( | $msg | ) |
Set the introductory message, overwriting any existing message.
string | $msg | Complete text of message to display |
Definition at line 750 of file HTMLForm.php.
References setPreText().
HTMLForm::setMessagePrefix | ( | $p | ) |
Set the prefix for various default messages.
string | $p |
Definition at line 1593 of file HTMLForm.php.
Referenced by MediaWiki\Extension\OATHAuth\Special\DisableOATHForUser\alterForm().
HTMLForm::setMethod | ( | $method = 'post' | ) |
Set the method used to submit the form.
string | $method |
Definition at line 1629 of file HTMLForm.php.
Referenced by SpecialCiteThisPage\alterForm(), SpecialChangeContentModel\alterForm(), and SpecialRedirect\alterForm().
HTMLForm::setName | ( | $name | ) |
string | $name | 'name' attribute for the form |
Definition at line 1530 of file HTMLForm.php.
HTMLForm::setPostText | ( | $msg | ) |
Set text at the end of the display.
string | $msg | Complete text of message to display |
Definition at line 924 of file HTMLForm.php.
HTMLForm::setPreText | ( | $msg | ) |
Set the introductory message HTML, overwriting any existing message.
string | $msg | Complete HTML of message to display |
Definition at line 764 of file HTMLForm.php.
Referenced by MediaWiki\Extension\OATHAuth\Special\DisableOATHForUser\alterForm(), and setIntro().
HTMLForm::setSubmitCallback | ( | $cb | ) |
Set a callback to a function to do something with the form once it's been successfully validated.
callable | $cb | The function will be passed the output from HTMLForm::filterDataForSubmit and this HTMLForm object, and must return as documented for HTMLForm::trySubmit |
Definition at line 723 of file HTMLForm.php.
HTMLForm::setSubmitDestructive | ( | ) |
Identify that the submit button in the form has a destructive action.
Definition at line 1374 of file HTMLForm.php.
Referenced by SpecialBlock\alterForm(), SpecialPasswordReset\alterForm(), and SpecialResetTokens\alterForm().
HTMLForm::setSubmitID | ( | $t | ) |
Set the id for the submit button.
string | $t |
Definition at line 1435 of file HTMLForm.php.
References $t.
HTMLForm::setSubmitName | ( | $name | ) |
string | $name | Submit button name |
Definition at line 1410 of file HTMLForm.php.
Referenced by UploadForm\__construct(), and McrUndoAction\alterForm().
HTMLForm::setSubmitText | ( | $t | ) |
Set the text for the submit button.
string | $t | Plaintext |
Definition at line 1362 of file HTMLForm.php.
References $t.
Referenced by UploadForm\__construct(), and setSubmitTextMsg().
HTMLForm::setSubmitTextMsg | ( | $msg | ) |
Set the text for the submit button to a message.
Definition at line 1388 of file HTMLForm.php.
References ContextSource\msg(), and setSubmitText().
Referenced by MarkpatrolledAction\alterForm(), McrUndoAction\alterForm(), PurgeAction\alterForm(), RevertAction\alterForm(), RollbackAction\alterForm(), UnwatchAction\alterForm(), WatchAction\alterForm(), SpecialBlock\alterForm(), SpecialChangeContentModel\alterForm(), SpecialChangeEmail\alterForm(), SpecialPageLanguage\alterForm(), SpecialPasswordReset\alterForm(), SpecialRandomInCategory\alterForm(), SpecialRedirect\alterForm(), and SpecialResetTokens\alterForm().
HTMLForm::setSubmitTooltip | ( | $name | ) |
string | $name | Tooltip for the submit button |
Definition at line 1421 of file HTMLForm.php.
Referenced by UploadForm\__construct(), and McrUndoAction\alterForm().
HTMLForm::setTableId | ( | $id | ) |
Set the id of the \<table\> or outermost \<div\> element.
string | $id | New value of the id attribute, or "" to remove |
Definition at line 1509 of file HTMLForm.php.
Referenced by SpecialBotPasswords\alterForm(), and SpecialChangeEmail\alterForm().
HTMLForm::setTitle | ( | $t | ) |
HTMLForm::setTokenSalt | ( | $salt | ) |
Set the salt for the edit token.
Only useful when the method is "post".
string | array | $salt | Salt to use |
Definition at line 1032 of file HTMLForm.php.
Referenced by MarkpatrolledAction\alterForm(), RevertAction\alterForm(), RollbackAction\alterForm(), WatchAction\alterForm(), and SpecialUserLogout\alterForm().
HTMLForm::setValidationErrorMessage | ( | $msg | ) |
Set a message to display on a validation error.
array | $msg | Array of valid inputs to wfMessage() (so each entry must itself be an array of arguments) |
Definition at line 737 of file HTMLForm.php.
HTMLForm::setWrapperAttributes | ( | $attributes | ) |
For internal use only.
Use is discouraged, and should only be used where support for gadgets/user scripts is warranted.
array | $attributes |
Definition at line 1560 of file HTMLForm.php.
HTMLForm::setWrapperLegend | ( | $legend | ) |
Prompt the whole form to be wrapped in a "<fieldset>", with this text as its "<legend>" element.
string | bool | $legend | If false, no wrapper or legend will be displayed. If true, a wrapper will be displayed, but no legend. If a string, a wrapper will be displayed with that string as a legend. The string will be escaped before being output (this doesn't support HTML). |
Definition at line 1547 of file HTMLForm.php.
Referenced by MediaWiki\Extension\OATHAuth\Special\DisableOATHForUser\alterForm(), SpecialLockdb\alterForm(), SpecialUnlockdb\alterForm(), and setWrapperLegendMsg().
HTMLForm::setWrapperLegendMsg | ( | $msg | ) |
Prompt the whole form to be wrapped in a "<fieldset>", with this message as its "<legend>" element.
Definition at line 1575 of file HTMLForm.php.
References ContextSource\msg(), and setWrapperLegend().
Referenced by McrRestoreAction\alterForm(), McrUndoAction\alterForm(), PurgeAction\alterForm(), RevertAction\alterForm(), RollbackAction\alterForm(), UnwatchAction\alterForm(), WatchAction\alterForm(), and SpecialBotPasswords\alterForm().
HTMLForm::show | ( | ) |
The here's-one-I-made-earlier option: do the submission if posted, or display the form with or without funky validation errors.
Reimplemented in UploadForm.
Definition at line 594 of file HTMLForm.php.
References displayForm(), StatusValue\isGood(), prepareForm(), and tryAuthorizedSubmit().
HTMLForm::showAlways | ( | ) |
Same as self::show with the difference, that the form will be added to the output, no matter, if the validation was good or not.
Definition at line 612 of file HTMLForm.php.
References displayForm(), prepareForm(), and tryAuthorizedSubmit().
HTMLForm::showCancel | ( | $show = true | ) |
Show a cancel button (or prevent it).
The button is not shown by default.
bool | $show |
Definition at line 1484 of file HTMLForm.php.
Referenced by McrUndoAction\alterForm().
HTMLForm::suppressDefaultSubmit | ( | $suppressSubmit = true | ) |
Stop a default submit button being shown for this form.
This implies that an alternate submit method must be provided manually.
bool | $suppressSubmit | Set to false to re-enable the button again |
Definition at line 1472 of file HTMLForm.php.
Referenced by SpecialBotPasswords\alterForm(), and SpecialResetTokens\alterForm().
HTMLForm::suppressReset | ( | $suppressReset = true | ) |
Stop a reset button being shown for this form.
bool | $suppressReset | Set to false to re-enable the button again |
Definition at line 1836 of file HTMLForm.php.
HTMLForm::tryAuthorizedSubmit | ( | ) |
Try submitting, with edit token check first.
Definition at line 556 of file HTMLForm.php.
References getMethod(), ContextSource\getRequest(), getUser(), and trySubmit().
Referenced by show(), and showAlways().
HTMLForm::trySubmit | ( | ) |
Validate all the fields, and call the submission callback function if everything is kosher.
MWException |
Reimplemented in UploadForm.
Definition at line 633 of file HTMLForm.php.
References $res, and filterDataForSubmit().
Referenced by tryAuthorizedSubmit().
HTMLForm::wasSubmitted | ( | ) |
Test whether the form was considered to have been submitted or not, i.e.
whether the last call to tryAuthorizedSubmit or trySubmit returned non-false.
This will return false until HTMLForm::tryAuthorizedSubmit or HTMLForm::trySubmit is called.
Definition at line 709 of file HTMLForm.php.
|
protected |
Wraps the given $section into an user-visible fieldset.
string | $legend | Legend text for the fieldset |
string | $section | The section content in plain Html |
array | $attributes | Additional attributes for the fieldset |
bool | $isRoot | Section is at the root of the tree |
Reimplemented in MediaWiki\Extension\OATHAuth\HTMLForm\OATHAuthOOUIHTMLForm, OOUIHTMLForm, and PreferencesFormOOUI.
Definition at line 1651 of file HTMLForm.php.
Referenced by displaySection().
HTMLForm::wrapForm | ( | $html | ) |
Wrap the form innards in an actual "<form>" element.
string | $html | HTML contents to wrap. |
Reimplemented in OOUIHTMLForm, VFormHTMLForm, and PreferencesFormOOUI.
Definition at line 1133 of file HTMLForm.php.
References getFormAttributes().
Referenced by getHTML().
|
protected |
Available formats in which to display the form.
Definition at line 280 of file HTMLForm.php.
|
protected |
Available formats in which to display the form.
Definition at line 291 of file HTMLForm.php.
|
protected |
Format in which to display form.
For viable options,
Definition at line 274 of file HTMLForm.php.
|
protected |
Form action URL.
false means we will use the URL to set Title
Definition at line 220 of file HTMLForm.php.
|
protected |
Form attribute autocomplete.
A typical value is "off". null does not set the attribute
Definition at line 241 of file HTMLForm.php.
|
protected |
-var array<array{name:string,value:string,label-message?:string,label?:string,label-raw?:string,id?:string,attribs?:array,flags?:string|string[],framed?:bool}>
Definition at line 249 of file HTMLForm.php.
|
protected |
Definition at line 190 of file HTMLForm.php.
|
protected |
|
protected |
HTMLForm::$mFieldData |
Definition at line 178 of file HTMLForm.php.
|
protected |
Definition at line 184 of file HTMLForm.php.
|
protected |
Definition at line 183 of file HTMLForm.php.
|
protected |
Definition at line 197 of file HTMLForm.php.
|
protected |
Definition at line 210 of file HTMLForm.php.
|
protected |
Definition at line 196 of file HTMLForm.php.
|
protected |
Definition at line 244 of file HTMLForm.php.
|
protected |
Definition at line 201 of file HTMLForm.php.
|
protected |
Definition at line 180 of file HTMLForm.php.
|
protected |
Definition at line 212 of file HTMLForm.php.
|
protected |
Definition at line 202 of file HTMLForm.php.
|
protected |
Definition at line 200 of file HTMLForm.php.
|
protected |
Definition at line 195 of file HTMLForm.php.
|
protected |
Definition at line 199 of file HTMLForm.php.
|
protected |
Definition at line 198 of file HTMLForm.php.
|
protected |
Definition at line 189 of file HTMLForm.php.
|
protected |
Definition at line 185 of file HTMLForm.php.
|
protected |
Definition at line 186 of file HTMLForm.php.
|
protected |
Definition at line 192 of file HTMLForm.php.
|
protected |
Definition at line 188 of file HTMLForm.php.
|
protected |
Definition at line 205 of file HTMLForm.php.
Referenced by VFormHTMLForm\getButtons().
|
protected |
Definition at line 206 of file HTMLForm.php.
Referenced by VFormHTMLForm\getButtons().
|
protected |
Definition at line 207 of file HTMLForm.php.
|
protected |
Definition at line 208 of file HTMLForm.php.
|
protected |
If true, sections that contain both fields and subsections will render their subsections before their fields.
Subclasses may set this to false to render subsections after fields instead.
Definition at line 267 of file HTMLForm.php.
|
protected |
Definition at line 203 of file HTMLForm.php.
|
protected |
Definition at line 211 of file HTMLForm.php.
|
protected |
Salt for the edit token.
Definition at line 258 of file HTMLForm.php.
|
protected |
Definition at line 243 of file HTMLForm.php.
|
protected |
Definition at line 193 of file HTMLForm.php.
|
protected |
Definition at line 213 of file HTMLForm.php.
|
protected |
Definition at line 252 of file HTMLForm.php.
|
protected |
Definition at line 251 of file HTMLForm.php.
|
static |
Definition at line 133 of file HTMLForm.php.