MediaWiki
master
|
Object handling generic submission, CSRF protection, layout and other logic for UI forms in a reusable manner. More...
Public Member Functions | |
__construct ( $descriptor, IContextSource $context, $messagePrefix='') | |
Build a new HTMLForm from an array of field attributes. More... | |
addButton ( $data) | |
Add a button to the form. More... | |
addFields ( $descriptor) | |
Add fields to the form. More... | |
addFooterHtml ( $html, $section=null) | |
Add footer HTML, inside the form. More... | |
addFooterText ( $msg, $section=null) | |
Add footer text, inside the form. More... | |
addHeaderHtml ( $html, $section=null) | |
Add HTML to the header, inside the form. More... | |
addHeaderText ( $msg, $section=null) | |
Add HTML to the header, inside the form. More... | |
addHiddenField ( $name, $value, array $attribs=[]) | |
Add a hidden field to the output Array values are discarded for security reasons (per WebRequest::getVal) More... | |
addHiddenFields (array $fields) | |
Add an array of hidden fields to the output Array values are discarded for security reasons (per WebRequest::getVal) More... | |
addPostHtml ( $html) | |
Add HTML to the end of the display. More... | |
addPostText ( $msg) | |
Add text to the end of the display. More... | |
addPreHtml ( $html) | |
Add HTML to introductory message. More... | |
addPreText ( $msg) | |
Add HTML to introductory message. More... | |
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. More... | |
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. More... | |
formatErrors ( $errors) | |
Format a stack of error messages into a single HTML string. More... | |
getAction () | |
Get the value for the action attribute of the form. More... | |
getBody () | |
Get the whole body of the form. More... | |
getButtons () | |
Get the submit and (potentially) reset buttons. More... | |
getDisplayFormat () | |
Getter for displayFormat. More... | |
getErrorsOrWarnings ( $elements, $elementsType) | |
Returns a formatted list of errors or warnings from the given elements. More... | |
getField ( $fieldname) | |
getFooterHtml ( $section=null) | |
Get footer HTML. More... | |
getFooterText ( $section=null) | |
Get footer text. More... | |
getHeaderHtml ( $section=null) | |
Get header HTML. More... | |
getHeaderText ( $section=null) | |
Get header text. More... | |
getHiddenFields () | |
Get the hidden fields that should go inside the form. More... | |
getHTML ( $submitResult) | |
Returns the raw HTML generated by the form. More... | |
getLegend ( $key) | |
Get a string to go in the "<legend>" of a section fieldset. More... | |
getMethod () | |
getPostHtml () | |
Get HTML at the end of the display. More... | |
getPreHtml () | |
Get the introductory message HTML. More... | |
getPreText () | |
Get the introductory message HTML. More... | |
getSubmitText () | |
Get the text for the submit button, either customised or a default. More... | |
getTitle () | |
hasField ( $fieldname) | |
loadData () | |
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. More... | |
prepareForm () | |
Prepare form for submission. More... | |
setAction ( $action) | |
Set the value for the action attribute of the form. More... | |
setAutocomplete ( $autocomplete) | |
Set the value for the autocomplete attribute of the form. More... | |
setCancelTarget ( $target) | |
Sets the target where the user is redirected to after clicking cancel. More... | |
setCollapsibleOptions ( $collapsedByDefault=false) | |
Enable collapsible mode, and set whether the form is collapsed by default. More... | |
setDisplayFormat ( $format) | |
Set format in which to display the form. More... | |
setFooterHtml ( $html, $section=null) | |
Set footer HTML, inside the form. More... | |
setFooterText ( $msg, $section=null) | |
Set footer text, inside the form. More... | |
setFormIdentifier ( $ident) | |
Set an internal identifier for this form. More... | |
setHeaderHtml ( $html, $section=null) | |
Set header HTML, inside the form. More... | |
setHeaderText ( $msg, $section=null) | |
Set header text, inside the form. More... | |
setId ( $id) | |
setIntro ( $msg) | |
Set the introductory message, overwriting any existing message. More... | |
setMessagePrefix ( $p) | |
Set the prefix for various default messages. More... | |
setMethod ( $method='post') | |
Set the method used to submit the form. More... | |
setName ( $name) | |
setPostHtml ( $html) | |
Set HTML at the end of the display. More... | |
setPostText ( $msg) | |
Set text at the end of the display. More... | |
setPreHtml ( $html) | |
Set the introductory message HTML, overwriting any existing message. More... | |
setPreText ( $msg) | |
Set the introductory message HTML, overwriting any existing message. More... | |
setSubmitCallback ( $cb) | |
Set a callback to a function to do something with the form once it's been successfully validated. More... | |
setSubmitDestructive () | |
Identify that the submit button in the form has a destructive action. More... | |
setSubmitID ( $t) | |
Set the id for the submit button. More... | |
setSubmitName ( $name) | |
setSubmitText ( $t) | |
Set the text for the submit button. More... | |
setSubmitTextMsg ( $msg) | |
Set the text for the submit button to a message. More... | |
setSubmitTooltip ( $name) | |
setTableId ( $id) | |
Set the id of the \<table\> or outermost \<div\> element. More... | |
setTitle ( $t) | |
Set the title for form submission. More... | |
setTokenSalt ( $salt) | |
Set the salt for the edit token. More... | |
setValidationErrorMessage ( $msg) | |
Set a message to display on a validation error. More... | |
setWrapperAttributes ( $attributes) | |
For internal use only. More... | |
setWrapperLegend ( $legend) | |
Prompt the whole form to be wrapped in a "<fieldset>", with this text as its "<legend>" element. More... | |
setWrapperLegendMsg ( $msg) | |
Prompt the whole form to be wrapped in a "<fieldset>", with this message as its "<legend>" element. More... | |
show () | |
The here's-one-I-made-earlier option: do the submission if posted, or display the form with or without funky validation errors. More... | |
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. More... | |
showCancel ( $show=true) | |
Show a cancel button (or prevent it). More... | |
suppressDefaultSubmit ( $suppressSubmit=true) | |
Stop a default submit button being shown for this form. More... | |
suppressReset ( $suppressReset=true) | |
Stop a reset button being shown for this form. More... | |
tryAuthorizedSubmit () | |
Try submitting, with edit token check first. More... | |
trySubmit () | |
Validate all the fields, and call the submission callback function if everything is kosher. More... | |
wasSubmitted () | |
Test whether the form was considered to have been submitted or not, i.e. More... | |
wrapForm ( $html) | |
Wrap the form innards in an actual "<form>" element. More... | |
![]() | |
canUseWikiPage () | |
Check whether a WikiPage object can be get with getWikiPage(). More... | |
exportSession () | |
Export the resolved user IP, HTTP headers, user ID, and session ID. More... | |
getActionName () | |
Get the action name for the current web request. More... | |
getAuthority () | |
getConfig () | |
getContext () | |
Get the base IContextSource object. More... | |
getCsrfTokenSet () | |
Get a repository to obtain and match CSRF tokens. More... | |
getLanguage () | |
getOutput () | |
getRequest () | |
getSkin () | |
getTiming () | |
getUser () | |
getWikiPage () | |
Get the WikiPage object. More... | |
msg ( $key,... $params) | |
Get a Message object with context set Parameters are the same as wfMessage() More... | |
setContext (IContextSource $context) | |
Static Public Member Functions | |
static | factory ( $displayFormat, $descriptor, IContextSource $context, $messagePrefix='') |
Construct a HTMLForm object for given display type. More... | |
static | getClassFromDescriptor ( $fieldname, &$descriptor) |
Get the HTMLFormField subclass for this descriptor. More... | |
static | loadInputFromParameters ( $fieldname, $descriptor, HTMLForm $parent=null) |
Initialise a new Object for the field. More... | |
Public Attributes | |
$mFieldData | |
Static Public Attributes | |
static string[] | $typeMappings |
A mapping of 'type' inputs onto standard HTMLFormField subclasses. More... | |
Protected Member Functions | |
formatSection (array $fieldsHtml, $sectionName, $anyFieldHasLabel) | |
Put a form section together from the individual fields' HTML, merging it and wrapping. More... | |
getCancelTargetURL () | |
getFormAttributes () | |
Get HTML attributes for the <form> tag. More... | |
getMessage ( $value) | |
Turns a *-message parameter (which could be a MessageSpecifier, or a message name, or a name + parameters array) into a Message. More... | |
loadFieldData () | |
Load data of form fields from the request. More... | |
wrapFieldSetSection ( $legend, $section, $attributes, $isRoot) | |
Wraps the given $section into a user-visible fieldset. More... | |
Protected Attributes | |
array | $availableDisplayFormats |
Available formats in which to display the form. More... | |
array | $availableSubclassDisplayFormats |
Available formats in which to display the form. More... | |
string | $displayFormat = 'table' |
Format in which to display form. More... | |
string false | $mAction = false |
Form action URL. More... | |
string null | $mAutocomplete = null |
Form attribute autocomplete. More... | |
array[] | $mButtons = [] |
$mCancelTarget | |
bool | $mCollapsed = false |
Whether the form is collapsed by default. More... | |
bool | $mCollapsible = false |
Whether the form can be collapsed. More... | |
$mFieldTree = [] | |
HTMLFormField[] | $mFlatFields = [] |
$mFooter = '' | |
$mFormIdentifier | |
$mHeader = '' | |
array[] | $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 | |
bool | $mSubSectionBeforeFields = true |
If true, sections that contain both fields and subsections will render their subsections before their fields. More... | |
$mTableId = '' | |
Title null | $mTitle |
string array | $mTokenSalt = '' |
Salt for the edit token. More... | |
$mUseMultipart = false | |
array[] | $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-messages-parse' – Flag to parse the messages in 'options-messages'. '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 153 of file HTMLForm.php.
HTMLForm::__construct | ( | $descriptor, | |
IContextSource | $context, | ||
$messagePrefix = '' |
|||
) |
Build a new HTMLForm from an array of field attributes.
array | $descriptor | Array of Field constructs, as described in the class documentation |
IContextSource | $context | Context used to fetch submitted form fields and generate localisation messages |
string | $messagePrefix | A prefix to go in front of default messages |
Definition at line 378 of file HTMLForm.php.
References addFields(), ContextSource\getConfig(), and ContextSource\setContext().
HTMLForm::addButton | ( | $data | ) |
Add a button to the form.
array | $data | Data to define the button:
|
Definition at line 1206 of file HTMLForm.php.
Referenced by McrUndoAction\alterForm(), and MediaWiki\Specials\SpecialBotPasswords\alterForm().
HTMLForm::addFields | ( | $descriptor | ) |
Add fields to the form.
array | $descriptor | Array of Field constructs, as described in the class documentation |
Reimplemented in PreferencesFormOOUI.
Definition at line 404 of file HTMLForm.php.
Referenced by __construct(), SpecialWhatLinksHere\alterForm(), and SpecialTags\processCreateTagForm().
HTMLForm::addFooterHtml | ( | $html, | |
$section = null |
|||
) |
Add footer HTML, inside the form.
string | $html | Complete text of message to display |
string | null | $section | The section to add the footer text to |
Definition at line 992 of file HTMLForm.php.
Referenced by addFooterText().
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 1048 of file HTMLForm.php.
References addFooterHtml().
Referenced by UploadForm\__construct().
HTMLForm::addHeaderHtml | ( | $html, | |
$section = null |
|||
) |
Add HTML to the header, inside the form.
string | $html | Additional HTML to display in header |
string | null | $section | The section to add the header to |
Definition at line 895 of file HTMLForm.php.
Referenced by addHeaderText(), MediaWiki\Specials\SpecialBlock\alterForm(), MediaWiki\Specials\SpecialChangeEmail\alterForm(), and SpecialUserLogout\alterForm().
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 952 of file HTMLForm.php.
References addHeaderHtml().
Referenced by UploadForm\getDescriptionSection().
HTMLForm::addHiddenField | ( | $name, | |
$value, | |||
array | $attribs = [] |
||
) |
Add a hidden field to the output Array values are discarded for security reasons (per WebRequest::getVal)
string | $name | Field name. This will be used exactly as entered |
mixed | $value | Field value |
array | $attribs |
Definition at line 1150 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 values are discarded for security reasons (per WebRequest::getVal)
array | $fields | Associative array of fields to add; mapping names to their values |
Definition at line 1171 of file HTMLForm.php.
Referenced by MediaWiki\Specials\SpecialChangeEmail\alterForm(), SpecialPasswordReset\alterForm(), and SpecialUserLogout\alterForm().
HTMLForm::addPostHtml | ( | $html | ) |
Add HTML to the end of the display.
string | $html | Complete text of message to display |
Definition at line 1086 of file HTMLForm.php.
Referenced by addPostText(), and SpecialUnblock\execute().
HTMLForm::addPostText | ( | $msg | ) |
Add text to the end of the display.
string | $msg | Complete text of message to display |
Definition at line 1124 of file HTMLForm.php.
References addPostHtml().
HTMLForm::addPreHtml | ( | $html | ) |
Add HTML to introductory message.
string | $html | Complete HTML of message to display |
Definition at line 835 of file HTMLForm.php.
Referenced by addPreText().
HTMLForm::addPreText | ( | $msg | ) |
Add HTML to introductory message.
string | $msg | Complete HTML of message to display |
Definition at line 871 of file HTMLForm.php.
References addPreHtml().
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() |
Definition at line 1267 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 1936 of file HTMLForm.php.
References Sanitizer\escapeIdForAttribute().
|
static |
Construct a HTMLForm object for given display type.
May return a HTMLForm subclass.
string | $displayFormat | |
array | $descriptor | Array of Field constructs, as described in the class documentation |
IContextSource | $context | Context used to fetch submitted form fields and generate localisation messages |
string | $messagePrefix | A prefix to go in front of default messages |
Definition at line 352 of file HTMLForm.php.
References $displayFormat.
Referenced by MediaWiki\Specials\SpecialActiveUsers\buildForm(), SpecialNewFiles\buildForm(), MediaWiki\Specials\SpecialAllMessages\execute(), MediaWiki\Specials\SpecialAutoblockList\execute(), MediaWiki\Specials\SpecialBlockList\execute(), MediaWiki\Specials\SpecialComparePages\execute(), MediaWiki\Specials\SpecialExport\execute(), MediaWiki\Specials\SpecialFileDuplicateSearch\execute(), MediaWiki\Specials\SpecialLinkSearch\execute(), SpecialPagesWithProp\execute(), SpecialUnblock\execute(), SpecialNewpages\form(), AuthManagerSpecialPage\getAuthForm(), LoginSignupSpecialPage\getAuthForm(), FormAction\getForm(), FormSpecialPage\getForm(), ImageListPager\getForm(), MediaWiki\Specials\SpecialContributions\getForm(), UsersPager\getPageHeader(), MediaWiki\Specials\SpecialMIMESearch\getPageHeader(), SpecialWithoutInterwiki\getPageHeader(), CategoryPager\getStartForm(), SpecialPrefixindex\namespacePrefixForm(), MediaWiki\Specials\SpecialAllPages\outputHTMLForm(), MediaWiki\Specials\SpecialEmailUser\sendEmailForm(), SpecialTags\showActivateDeactivateForm(), SpecialTags\showDeleteTagForm(), SpecialRevisionDelete\showForm(), SpecialProtectedpages\showOptions(), LogEventsList\showOptions(), SpecialPreferences\showResetForm(), and MediaWiki\Specials\SpecialEmailUser\userForm().
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 2132 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 1586 of file HTMLForm.php.
|
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 2029 of file HTMLForm.php.
References Sanitizer\escapeIdForAttribute().
HTMLForm::getAction | ( | ) |
Get the value for the action attribute of the form.
Definition at line 2172 of file HTMLForm.php.
References getTitle().
HTMLForm::getBody | ( | ) |
Get the whole body of the form.
Reimplemented in PreferencesFormOOUI, and OOUIHTMLForm.
Definition at line 1532 of file HTMLForm.php.
HTMLForm::getButtons | ( | ) |
Get the submit and (potentially) reset buttons.
Reimplemented in OOUIHTMLForm.
Definition at line 1429 of file HTMLForm.php.
References Xml\submitButton().
|
protected |
Definition at line 1755 of file HTMLForm.php.
Referenced by OOUIHTMLForm\getButtons().
|
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 524 of file HTMLForm.php.
HTMLForm::getDisplayFormat | ( | ) |
Getter for displayFormat.
Definition at line 503 of file HTMLForm.php.
References $displayFormat.
Referenced by 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 1545 of file HTMLForm.php.
HTMLForm::getField | ( | $fieldname | ) |
string | $fieldname |
DomainException | on invalid field name |
Definition at line 450 of file HTMLForm.php.
References hasField().
HTMLForm::getFooterHtml | ( | $section = null | ) |
Get footer HTML.
string | null | $section | The section to get the footer text for |
Definition at line 1031 of file HTMLForm.php.
References $mFooter.
Referenced by getFooterText().
HTMLForm::getFooterText | ( | $section = null | ) |
Get footer text.
string | null | $section | The section to get the footer text for |
Definition at line 1074 of file HTMLForm.php.
References getFooterHtml().
|
protected |
Get HTML attributes for the <form>
tag.
Reimplemented in VFormHTMLForm.
Definition at line 1344 of file HTMLForm.php.
Referenced by OOUIHTMLForm\wrapForm().
HTMLForm::getHeaderHtml | ( | $section = null | ) |
Get header HTML.
string | null | $section | The section to get the header text for |
Reimplemented in OOUIHTMLForm.
Definition at line 935 of file HTMLForm.php.
References $mHeader.
Referenced by getHeaderText().
HTMLForm::getHeaderText | ( | $section = null | ) |
Get header text.
string | null | $section | The section to get the header text for |
Definition at line 979 of file HTMLForm.php.
References getHeaderHtml().
HTMLForm::getHiddenFields | ( | ) |
Get the hidden fields that should go inside the form.
Definition at line 1396 of file HTMLForm.php.
References getUser().
HTMLForm::getHTML | ( | $submitResult | ) |
Returns the raw HTML generated by the form.
bool | string | array | Status | $submitResult | Output from HTMLForm::trySubmit() |
Reimplemented in VFormHTMLForm.
Definition at line 1300 of file HTMLForm.php.
Referenced by 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 EditWatchlistNormalHTMLForm, and PreferencesFormOOUI.
Definition at line 2145 of file HTMLForm.php.
|
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 2213 of file HTMLForm.php.
References Message\newFromSpecifier().
Referenced by OOUIHTMLForm\getButtons(), and OOUIHTMLForm\getErrorsOrWarnings().
HTMLForm::getMethod | ( | ) |
Definition at line 1901 of file HTMLForm.php.
Referenced by tryAuthorizedSubmit(), and trySubmit().
HTMLForm::getPostHtml | ( | ) |
Get HTML at the end of the display.
Definition at line 1112 of file HTMLForm.php.
References $mPost.
HTMLForm::getPreHtml | ( | ) |
Get the introductory message HTML.
Definition at line 847 of file HTMLForm.php.
References $mPre.
Referenced by getPreText().
HTMLForm::getPreText | ( | ) |
Get the introductory message HTML.
Definition at line 882 of file HTMLForm.php.
References getPreHtml().
HTMLForm::getSubmitText | ( | ) |
Get the text for the submit button, either customised or a default.
Definition at line 1648 of file HTMLForm.php.
Referenced by OOUIHTMLForm\getButtons().
HTMLForm::getTitle | ( | ) |
Reimplemented from ContextSource.
Definition at line 1881 of file HTMLForm.php.
References getContext().
Referenced by UploadForm\__construct(), PreferencesFormOOUI\addFields(), and MediaWiki\Preferences\DefaultPreferencesFactory\submitForm().
HTMLForm::hasField | ( | $fieldname | ) |
string | $fieldname |
Definition at line 441 of file HTMLForm.php.
Referenced by getField().
HTMLForm::loadData | ( | ) |
Definition at line 2069 of file HTMLForm.php.
|
protected |
Load data of form fields from the request.
Definition at line 2076 of file HTMLForm.php.
References MediaWiki\Rest\Handler\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 VFormHTMLForm, and OOUIHTMLForm.
Definition at line 555 of file HTMLForm.php.
Referenced by HTMLFormFieldCloner\createFieldsForKey().
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 2226 of file HTMLForm.php.
HTMLForm::prepareForm | ( | ) |
Prepare form for submission.
MWException |
Definition at line 580 of file HTMLForm.php.
References ContextSource\getRequest(), and loadFieldData().
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 2159 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 2201 of file HTMLForm.php.
HTMLForm::setCancelTarget | ( | $target | ) |
Sets the target where the user is redirected to after clicking cancel.
LinkTarget | PageReference | string | $target | Target as an object or an URL |
Definition at line 1742 of file HTMLForm.php.
References TitleValue\castPageToLinkTarget().
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 1333 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 467 of file HTMLForm.php.
References ContextSource\getConfig().
HTMLForm::setFooterHtml | ( | $html, | |
$section = null |
|||
) |
Set footer HTML, inside the form.
string | $html | Complete text of message to display |
string | null | $section | The section to add the footer text to |
Definition at line 1014 of file HTMLForm.php.
Referenced by setFooterText().
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 1062 of file HTMLForm.php.
References setFooterHtml().
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 1703 of file HTMLForm.php.
Referenced by MediaWiki\Specials\SpecialChangeContentModel\alterForm().
HTMLForm::setHeaderHtml | ( | $html, | |
$section = null |
|||
) |
Set header HTML, inside the form.
string | $html | Complete HTML of header to display |
string | null | $section | The section to add the header to |
Definition at line 917 of file HTMLForm.php.
Referenced by MediaWiki\Specials\SpecialBlock\alterForm(), SpecialPasswordReset\alterForm(), SpecialTags\processCreateTagForm(), and setHeaderText().
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 966 of file HTMLForm.php.
References setHeaderHtml().
HTMLForm::setId | ( | $id | ) |
string | $id | DOM id for the form |
Definition at line 1785 of file HTMLForm.php.
Referenced by UploadForm\__construct(), McrUndoAction\alterForm(), MediaWiki\Specials\SpecialBotPasswords\alterForm(), and MediaWiki\Specials\SpecialChangeEmail\alterForm().
HTMLForm::setIntro | ( | $msg | ) |
Set the introductory message, overwriting any existing message.
string | $msg | Complete text of message to display |
Definition at line 809 of file HTMLForm.php.
References setPreHtml().
HTMLForm::setMessagePrefix | ( | $p | ) |
Set the prefix for various default messages.
string | $p |
Definition at line 1858 of file HTMLForm.php.
HTMLForm::setMethod | ( | $method = 'post' | ) |
Set the method used to submit the form.
string | $method |
Definition at line 1892 of file HTMLForm.php.
HTMLForm::setName | ( | $name | ) |
string | $name | 'name' attribute for the form |
Definition at line 1795 of file HTMLForm.php.
HTMLForm::setPostHtml | ( | $html | ) |
Set HTML at the end of the display.
string | $html | Complete text of message to display |
Definition at line 1100 of file HTMLForm.php.
Referenced by setPostText().
HTMLForm::setPostText | ( | $msg | ) |
Set text at the end of the display.
string | $msg | Complete text of message to display |
Definition at line 1136 of file HTMLForm.php.
References setPostHtml().
HTMLForm::setPreHtml | ( | $html | ) |
Set the introductory message HTML, overwriting any existing message.
string | $html | Complete HTML of message to display |
Definition at line 821 of file HTMLForm.php.
Referenced by setIntro(), and setPreText().
HTMLForm::setPreText | ( | $msg | ) |
Set the introductory message HTML, overwriting any existing message.
string | $msg | Complete HTML of message to display |
Definition at line 859 of file HTMLForm.php.
References setPreHtml().
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 780 of file HTMLForm.php.
HTMLForm::setSubmitDestructive | ( | ) |
Identify that the submit button in the form has a destructive action.
Definition at line 1621 of file HTMLForm.php.
Referenced by MediaWiki\Specials\SpecialBlock\alterForm(), SpecialPasswordReset\alterForm(), and SpecialResetTokens\alterForm().
HTMLForm::setSubmitID | ( | $t | ) |
Set the id for the submit button.
string | $t |
Definition at line 1682 of file HTMLForm.php.
References $t.
Referenced by MediaWiki\Specials\SpecialChangeEmail\alterForm().
HTMLForm::setSubmitName | ( | $name | ) |
string | $name | Submit button name |
Definition at line 1657 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 1609 of file HTMLForm.php.
References $t.
HTMLForm::setSubmitTextMsg | ( | $msg | ) |
Set the text for the submit button to a message.
Definition at line 1635 of file HTMLForm.php.
Referenced by UploadForm\__construct(), MarkpatrolledAction\alterForm(), McrUndoAction\alterForm(), PurgeAction\alterForm(), RevertAction\alterForm(), RollbackAction\alterForm(), UnwatchAction\alterForm(), WatchAction\alterForm(), MediaWiki\Specials\SpecialBlock\alterForm(), MediaWiki\Specials\SpecialChangeContentModel\alterForm(), MediaWiki\Specials\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 1668 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 1774 of file HTMLForm.php.
Referenced by MediaWiki\Specials\SpecialBotPasswords\alterForm(), and MediaWiki\Specials\SpecialChangeEmail\alterForm().
HTMLForm::setTitle | ( | $t | ) |
Set the title for form submission.
PageReference | $t | The page the form is on/should be posted to |
Definition at line 1871 of file HTMLForm.php.
References $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 1247 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 795 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 1825 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 1812 of file HTMLForm.php.
Referenced by MediaWiki\Specials\SpecialLockdb\alterForm(), and SpecialUnlockdb\alterForm().
HTMLForm::setWrapperLegendMsg | ( | $msg | ) |
Prompt the whole form to be wrapped in a "<fieldset>", with this message as its "<legend>" element.
Definition at line 1840 of file HTMLForm.php.
Referenced by McrRestoreAction\alterForm(), McrUndoAction\alterForm(), PurgeAction\alterForm(), RevertAction\alterForm(), RollbackAction\alterForm(), UnwatchAction\alterForm(), WatchAction\alterForm(), MediaWiki\Specials\SpecialBotPasswords\alterForm(), and SpecialWhatLinksHere\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 637 of file HTMLForm.php.
References displayForm(), StatusValue\isGood(), prepareForm(), and tryAuthorizedSubmit().
Referenced by SpecialUnblock\execute().
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 655 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 1731 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 1719 of file HTMLForm.php.
Referenced by MediaWiki\Specials\SpecialBotPasswords\alterForm(), SpecialResetTokens\alterForm(), PreferencesFormOOUI\setOptionsEditable(), and PreferencesFormOOUI\setPrivateInfoEditable().
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 2116 of file HTMLForm.php.
HTMLForm::tryAuthorizedSubmit | ( | ) |
Try submitting, with edit token check first.
Definition at line 598 of file HTMLForm.php.
References $mFormIdentifier, getMethod(), ContextSource\getRequest(), ContextSource\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 677 of file HTMLForm.php.
References $mSubmitCallback, $res, filterDataForSubmit(), getMethod(), ContextSource\getRequest(), StatusValue\newGood(), and Status\wrap().
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 766 of file HTMLForm.php.
References $mWasSubmitted.
|
protected |
Wraps the given $section into a 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 PreferencesFormOOUI, and OOUIHTMLForm.
Definition at line 1915 of file HTMLForm.php.
References Xml\fieldset().
HTMLForm::wrapForm | ( | $html | ) |
Wrap the form innards in an actual "<form>" element.
string | $html | HTML contents to wrap. |
Reimplemented in PreferencesFormOOUI, VFormHTMLForm, and OOUIHTMLForm.
Definition at line 1378 of file HTMLForm.php.
References Xml\fieldset().
|
protected |
Available formats in which to display the form.
Definition at line 317 of file HTMLForm.php.
|
protected |
Available formats in which to display the form.
Definition at line 328 of file HTMLForm.php.
|
protected |
Format in which to display form.
For viable options,
Definition at line 311 of file HTMLForm.php.
Referenced by factory(), and getDisplayFormat().
|
protected |
Form action URL.
false means we will use the URL to set Title
Definition at line 252 of file HTMLForm.php.
|
protected |
Form attribute autocomplete.
A typical value is "off". null does not set the attribute
Definition at line 273 of file HTMLForm.php.
|
protected |
Definition at line 285 of file HTMLForm.php.
|
protected |
Definition at line 217 of file HTMLForm.php.
|
protected |
|
protected |
HTMLForm::$mFieldData |
Definition at line 205 of file HTMLForm.php.
|
protected |
Definition at line 211 of file HTMLForm.php.
|
protected |
Definition at line 210 of file HTMLForm.php.
|
protected |
Definition at line 228 of file HTMLForm.php.
Referenced by getFooterHtml().
|
protected |
Definition at line 241 of file HTMLForm.php.
Referenced by tryAuthorizedSubmit().
|
protected |
Definition at line 227 of file HTMLForm.php.
Referenced by getHeaderHtml().
|
protected |
Definition at line 280 of file HTMLForm.php.
|
protected |
Definition at line 232 of file HTMLForm.php.
|
protected |
Definition at line 207 of file HTMLForm.php.
|
protected |
Definition at line 244 of file HTMLForm.php.
|
protected |
Definition at line 233 of file HTMLForm.php.
|
protected |
Definition at line 231 of file HTMLForm.php.
Referenced by getPostHtml().
|
protected |
Definition at line 226 of file HTMLForm.php.
Referenced by getPreHtml().
|
protected |
Definition at line 230 of file HTMLForm.php.
|
protected |
Definition at line 229 of file HTMLForm.php.
|
protected |
Definition at line 216 of file HTMLForm.php.
|
protected |
Definition at line 212 of file HTMLForm.php.
|
protected |
Definition at line 213 of file HTMLForm.php.
|
protected |
Definition at line 219 of file HTMLForm.php.
Referenced by trySubmit().
|
protected |
Definition at line 215 of file HTMLForm.php.
Referenced by OOUIHTMLForm\getButtons().
|
protected |
Definition at line 236 of file HTMLForm.php.
Referenced by OOUIHTMLForm\getButtons().
|
protected |
Definition at line 237 of file HTMLForm.php.
Referenced by OOUIHTMLForm\getButtons().
|
protected |
Definition at line 238 of file HTMLForm.php.
|
protected |
Definition at line 239 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 304 of file HTMLForm.php.
|
protected |
Definition at line 234 of file HTMLForm.php.
|
protected |
Definition at line 243 of file HTMLForm.php.
|
protected |
Salt for the edit token.
Definition at line 294 of file HTMLForm.php.
|
protected |
Definition at line 275 of file HTMLForm.php.
|
protected |
Definition at line 224 of file HTMLForm.php.
|
protected |
Definition at line 245 of file HTMLForm.php.
Referenced by wasSubmitted().
|
protected |
Definition at line 288 of file HTMLForm.php.
|
protected |
Definition at line 287 of file HTMLForm.php.
|
static |
A mapping of 'type' inputs onto standard HTMLFormField subclasses.
Definition at line 157 of file HTMLForm.php.
Referenced by AuthManagerSpecialPage\addTabIndex(), and HTMLExpiryField\getFieldByType().