MediaWiki master
MediaWiki\HTMLForm\OOUIHTMLForm Class Reference

Compact stacked vertical format for forms, implemented using OOUI widgets. More...

Inherits MediaWiki\HTMLForm\HTMLForm.

Inherited by EditWatchlistNormalHTMLForm, and PreferencesFormOOUI.

Collaboration diagram for MediaWiki\HTMLForm\OOUIHTMLForm:

Public Member Functions

 __construct ( $descriptor, $context=null, $messagePrefix='')
 
 getBody ()
 Get the whole body of the form.
 
 getButtons ()
 Get the submit and (potentially) reset buttons.
 
 getErrorsOrWarnings ( $elements, $elementsType)
 
 getHeaderHtml ( $section=null)
 Get header HTML.
 
 wrapForm ( $html)
 Wrap the form innards in an actual "<form>" element.
 
- Public Member Functions inherited from MediaWiki\HTMLForm\HTMLForm
 __construct ( $descriptor, IContextSource $context, $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.
 
 addFooterHtml ( $html, $section=null)
 Add footer HTML, inside the form.
 
 addFooterText ( $msg, $section=null)
 Add footer text, inside the form.
 
 addHeaderHtml ( $html, $section=null)
 Add HTML to the header, 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 Array values are discarded for security reasons (per WebRequest::getVal)
 
 addHiddenFields (array $fields)
 Add an array of hidden fields to the output Array values are discarded for security reasons (per WebRequest::getVal)
 
 addPostHtml ( $html)
 Add HTML to the end of the display.
 
 addPostText ( $msg)
 Add text to the end of the display.
 
 addPreHtml ( $html)
 Add HTML to introductory message.
 
 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.
 
 getDisplayFormat ()
 Getter for displayFormat.
 
 getField ( $fieldname)
 
 getFooterHtml ( $section=null)
 Get footer HTML.
 
 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 ()
 
 getPostHtml ()
 Get HTML at the end of the display.
 
 getPreHtml ()
 Get the introductory message HTML.
 
 getPreText ()
 Get the introductory message HTML.
 
 getSubmitText ()
 Get the text for the submit button, either customised or a default.
 
 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.
 
 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.
 
 setFooterHtml ( $html, $section=null)
 Set footer HTML, inside the form.
 
 setFooterText ( $msg, $section=null)
 Set footer text, inside the form.
 
 setFormIdentifier (string $ident, bool $single=false)
 Set an internal identifier for this form.
 
 setHeaderHtml ( $html, $section=null)
 Set header HTML, inside the 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)
 
 setPostHtml ( $html)
 Set HTML at the end of the display.
 
 setPostText ( $msg)
 Set text at the end of the display.
 
 setPreHtml ( $html)
 Set the introductory message HTML, overwriting any existing message.
 
 setPreText ( $msg)
 Set the introductory message HTML, overwriting any existing message.
 
 setSections ( $sections)
 Set an array of information about sections.
 
 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.
 
 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.
 
- Public Member Functions inherited from MediaWiki\Context\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.
 
 getActionName ()
 Get the action name for the current web request.
 
 getAuthority ()
 
 getConfig ()
 
 getContext ()
 Get the base IContextSource object.
 
 getCsrfTokenSet ()
 Get a repository to obtain and match CSRF tokens.
 
 getLanguage ()
 
 getLanguageCode ()
 
 getOutput ()
 
 getRequest ()
 
 getSkin ()
 
 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 loadInputFromParameters ( $fieldname, $descriptor, HTMLForm $parent=null)
 Initialise a new Object for the field.
 
- Static Public Member Functions inherited from MediaWiki\HTMLForm\HTMLForm
static factory ( $displayFormat, $descriptor, IContextSource $context, $messagePrefix='')
 Construct a HTMLForm object for given display type.
 
static getClassFromDescriptor ( $fieldname, &$descriptor)
 Get the HTMLFormField subclass for this descriptor.
 

Protected Member Functions

 formatField (HTMLFormField $field, $value)
 Generate the HTML for an individual field in the current display format.
Since
1.41
Stability: stable
to override
Parameters
HTMLFormField$field
mixed$value
Returns
string|Stringable HTML

 
 formatFormHeader ()
 
 formatSection (array $fieldsHtml, $sectionName, $anyFieldHasLabel)
 Put a form section together from the individual fields' HTML, merging it and wrapping.
 
 wrapFieldSetSection ( $legend, $section, $attributes, $isRoot)
 Wraps the given $section into a user-visible fieldset.
Stability: stable
to override
Parameters
string$legendLegend text for the fieldset
string$sectionThe section content in plain Html
array$attributesAdditional attributes for the fieldset
bool$isRootSection is at the root of the tree
Returns
string The fieldset's Html

 
- Protected Member Functions inherited from MediaWiki\HTMLForm\HTMLForm
 getCancelTargetURL ()
 
 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.
 
 loadFieldData ()
 Load data of form fields from the request.
 

Protected Attributes

 $displayFormat = 'ooui'
 
- Protected Attributes inherited from MediaWiki\HTMLForm\HTMLForm
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.
 
string false $mAction = false
 Form action URL.
 
string null $mAutocomplete = null
 Form attribute autocomplete.
 
array[] $mButtons = []
 
 $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 = ''
 
array[] $mHiddenFields = []
 
 $mId
 
 $mMessagePrefix
 
 $mMethod = 'post'
 
 $mName
 
 $mPost = ''
 
 $mPre = ''
 
 $mSectionFooters = []
 
 $mSectionHeaders = []
 
array[] $mSections = []
 Additional information about form sections.
 
 $mShowCancel = false
 
 $mShowSubmit = true
 
 $mSingleForm = false
 
 $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.
 
 $mTableId = ''
 
Title null $mTitle
 
string array $mTokenSalt = ''
 Salt for the edit token.
 
 $mUseMultipart = false
 
array[] $mValidationErrorMessage
 
 $mWasSubmitted = false
 
 $mWrapperAttributes = []
 
 $mWrapperLegend = false
 

Additional Inherited Members

- Public Attributes inherited from MediaWiki\HTMLForm\HTMLForm
 $mFieldData
 
- Static Public Attributes inherited from MediaWiki\HTMLForm\HTMLForm
static string[] $typeMappings
 A mapping of 'type' inputs onto standard HTMLFormField subclasses.
 

Detailed Description

Compact stacked vertical format for forms, implemented using OOUI widgets.

Stability: stable
to extend

Definition at line 37 of file OOUIHTMLForm.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\HTMLForm\OOUIHTMLForm::__construct ( $descriptor,
$context = null,
$messagePrefix = '' )
Stability: stable
to call

Definition at line 45 of file OOUIHTMLForm.php.

References MediaWiki\Context\ContextSource\getOutput().

Member Function Documentation

◆ formatField()

MediaWiki\HTMLForm\OOUIHTMLForm::formatField ( HTMLFormField $field,
$value )
protected

Generate the HTML for an individual field in the current display format.

Since
1.41
Stability: stable
to override
Parameters
HTMLFormField$field
mixed$value
Returns
string|Stringable HTML

Returns
\OOUI\FieldLayout HTML

Reimplemented from MediaWiki\HTMLForm\HTMLForm.

Definition at line 173 of file OOUIHTMLForm.php.

References MediaWiki\HTMLForm\HTMLFormField\getOOUI().

◆ formatFormHeader()

MediaWiki\HTMLForm\OOUIHTMLForm::formatFormHeader ( )
protected

◆ formatSection()

MediaWiki\HTMLForm\OOUIHTMLForm::formatSection ( array $fieldsHtml,
$sectionName,
$anyFieldHasLabel )
protected

Put a form section together from the individual fields' HTML, merging it and wrapping.

Parameters
\\OOUI\\FieldLayout[]$fieldsHtmlArray of outputs from formatField()
string$sectionName
bool$anyFieldHasLabelUnused
Returns
string HTML

Reimplemented from MediaWiki\HTMLForm\HTMLForm.

Definition at line 184 of file OOUIHTMLForm.php.

◆ getBody()

MediaWiki\HTMLForm\OOUIHTMLForm::getBody ( )

Get the whole body of the form.

Stability: stable
to override
Returns
string

Reimplemented from MediaWiki\HTMLForm\HTMLForm.

Reimplemented in PreferencesFormOOUI.

Definition at line 282 of file OOUIHTMLForm.php.

References MediaWiki\HTMLForm\OOUIHTMLForm\formatFormHeader().

◆ getButtons()

MediaWiki\HTMLForm\OOUIHTMLForm::getButtons ( )

◆ getErrorsOrWarnings()

MediaWiki\HTMLForm\OOUIHTMLForm::getErrorsOrWarnings ( $elements,
$elementsType )
Parameters
string | array | Status$elements
string$elementsType
Returns
string

Reimplemented from MediaWiki\HTMLForm\HTMLForm.

Definition at line 208 of file OOUIHTMLForm.php.

References MediaWiki\HTMLForm\HTMLForm\getMessage().

◆ getHeaderHtml()

MediaWiki\HTMLForm\OOUIHTMLForm::getHeaderHtml ( $section = null)

Get header HTML.

Stability: stable
to override
Parameters
string | null$sectionThe section to get the header text for
Since
1.38
Returns
string HTML

Reimplemented from MediaWiki\HTMLForm\HTMLForm.

Definition at line 247 of file OOUIHTMLForm.php.

◆ loadInputFromParameters()

static MediaWiki\HTMLForm\OOUIHTMLForm::loadInputFromParameters ( $fieldname,
$descriptor,
HTMLForm $parent = null )
static

Initialise a new Object for the field.

Stability: stable
to override
Parameters
string$fieldnameName of the field
array$descriptorInput Descriptor, as described in the class documentation
HTMLForm | null$parentParent instance of HTMLForm
Warning
Not passing (or passing null) for $parent is deprecated as of 1.40
Returns
HTMLFormField Instance of a subclass of HTMLFormField

Reimplemented from MediaWiki\HTMLForm\HTMLForm.

Definition at line 53 of file OOUIHTMLForm.php.

◆ wrapFieldSetSection()

MediaWiki\HTMLForm\OOUIHTMLForm::wrapFieldSetSection ( $legend,
$section,
$attributes,
$isRoot )
protected

Wraps the given $section into a user-visible fieldset.

Stability: stable
to override
Parameters
string$legendLegend text for the fieldset
string$sectionThe section content in plain Html
array$attributesAdditional attributes for the fieldset
bool$isRootSection is at the root of the tree
Returns
string The fieldset's Html

Returns
\OOUI\PanelLayout

Reimplemented from MediaWiki\HTMLForm\HTMLForm.

Reimplemented in PreferencesFormOOUI.

Definition at line 148 of file OOUIHTMLForm.php.

◆ wrapForm()

MediaWiki\HTMLForm\OOUIHTMLForm::wrapForm ( $html)

Wrap the form innards in an actual "<form>" element.

Stability: stable
to override
Parameters
string$htmlHTML contents to wrap.
Returns
string|\OOUI\Tag Wrapped HTML.

Reimplemented from MediaWiki\HTMLForm\HTMLForm.

Reimplemented in PreferencesFormOOUI.

Definition at line 286 of file OOUIHTMLForm.php.

References MediaWiki\HTMLForm\HTMLForm\getFormAttributes().

Member Data Documentation

◆ $displayFormat

MediaWiki\HTMLForm\OOUIHTMLForm::$displayFormat = 'ooui'
protected

Definition at line 51 of file OOUIHTMLForm.php.


The documentation for this class was generated from the following file: