BlueSpice MediaWiki REL1_27
 All Classes Namespaces Files Functions Variables Groups Pages
HTMLFormField Class Reference
Inheritance diagram for HTMLFormField:

Public Member Functions

 getInputHTML ($value)
 
 getInputOOUI ($value)
 
 canDisplayErrors ()
 
 msg ()
 
 hasVisibleOutput ()
 
 isHidden ($alldata)
 
 cancelSubmit ($value, $alldata)
 
 validate ($value, $alldata)
 
 filter ($value, $alldata)
 
 setShowEmptyLabel ($show)
 
 loadDataFromRequest ($request)
 
 __construct ($params)
 
 getTableRow ($value)
 
 getDiv ($value)
 
 getOOUI ($value)
 
 getRaw ($value)
 
 getVForm ($value)
 
 getInline ($value)
 
 getHelpTextHtmlTable ($helptext)
 
 getHelpTextHtmlDiv ($helptext)
 
 getHelpTextHtmlRaw ($helptext)
 
 getHelpText ()
 
 getErrorsAndErrorClass ($value)
 
 getErrorsRaw ($value)
 
 getLabel ()
 
 getLabelHtml ($cellAttributes=[])
 
 getDefault ()
 
 getTooltipAndAccessKey ()
 
 getAttributes (array $list)
 
 getOptions ()
 
 getOptionsOOUI ()
 
 skipLoadData ($request)
 

Static Public Member Functions

static forceToStringRecursive ($array)
 
static flattenOptions ($options)
 

Public Attributes

 $mParams
 
 $mParent
 

Protected Member Functions

 getNearestFieldByName ($alldata, $name)
 
 isHiddenRecurse (array $alldata, array $params)
 
 needsLabel ()
 
 getLabelAlignOOUI ()
 
 getFieldLayoutOOUI ($inputField, $config)
 
 getMessage ($value)
 

Static Protected Member Functions

static formatErrors ($errors)
 

Protected Attributes

 $mValidationCallback
 
 $mFilterCallback
 
 $mName
 
 $mDir
 
 $mLabel
 
 $mID
 
 $mClass = ''
 
 $mVFormClass = ''
 
 $mHelpClass = false
 
 $mDefault
 
 $mOptions = false
 
 $mOptionsLabelsNotFromMessage = false
 
 $mHideIf = null
 
 $mShowEmptyLabels = true
 

Detailed Description

The parent class to generate form fields. Any field type should be a subclass of this.

Constructor & Destructor Documentation

HTMLFormField::__construct (   $params)

Initialise the object

Parameters
array$paramsAssociative Array. See HTMLForm doc for syntax.
Since
1.22 The 'label' attribute no longer accepts raw HTML, use 'label-raw' instead
Exceptions
MWException

Member Function Documentation

HTMLFormField::cancelSubmit (   $value,
  $alldata 
)

Override this function if the control can somehow trigger a form submission that shouldn't actually submit the HTMLForm.

Since
1.23
Parameters
string | array$valueThe value the field was submitted with
array$alldataThe data collected from the form
Returns
bool True to cancel the submission
HTMLFormField::canDisplayErrors ( )

True if this field type is able to display errors; false if validation errors need to be displayed in the main HTMLForm error area.

Returns
bool
static HTMLFormField::flattenOptions (   $options)
static

flatten an array of options to a single array, for instance, a set of "<options>" inside "<optgroups>".

Parameters
array$optionsAssociative Array with values either Strings or Arrays
Returns
array Flattened input
static HTMLFormField::forceToStringRecursive (   $array)
static

Recursively forces values in an array to strings, because issues arise with integer 0 as a value.

Parameters
array$array
Returns
array
static HTMLFormField::formatErrors (   $errors)
staticprotected

Formats one or more errors as accepted by field validation-callback.

Parameters
string | Message | array$errorsArray of strings or Message instances
Returns
string HTML
Since
1.18
HTMLFormField::getAttributes ( array  $list)

Returns the given attributes from the parameters

Parameters
array$listList of attributes to get
Returns
array Attributes
HTMLFormField::getDiv (   $value)

Get the complete div for the input, including help text, labels, and whatever.

Since
1.20
Parameters
string$valueThe value to set the input to.
Returns
string Complete HTML table row.
HTMLFormField::getErrorsAndErrorClass (   $value)

Determine form errors to display and their classes

Since
1.20
Parameters
string$valueThe value of the input
Returns
array array( $errors, $errorClass )
HTMLFormField::getErrorsRaw (   $value)

Determine form errors to display, returning them in an array.

Since
1.26
Parameters
string$valueThe value of the input
Returns
string[] Array of error HTML strings
HTMLFormField::getFieldLayoutOOUI (   $inputField,
  $config 
)
protected

Get a FieldLayout (or subclass thereof) to wrap this field in when using OOUI output.

Returns
OOUI|OOUI
HTMLFormField::getHelpText ( )

Determine the help text to display

Since
1.20
Returns
string HTML
HTMLFormField::getHelpTextHtmlDiv (   $helptext)

Generate help text HTML in div format

Since
1.20
Parameters
string | null$helptext
Returns
string
HTMLFormField::getHelpTextHtmlRaw (   $helptext)

Generate help text HTML formatted for raw output

Since
1.20
Parameters
string | null$helptext
Returns
string
HTMLFormField::getHelpTextHtmlTable (   $helptext)

Generate help text HTML in table format

Since
1.20
Parameters
string | null$helptext
Returns
string
HTMLFormField::getInline (   $value)

Get the complete field as an inline element.

Since
1.25
Parameters
string$valueThe value to set the input to.
Returns
string Complete HTML inline element
HTMLFormField::getInputHTML (   $value)
abstract

This function must be implemented to return the HTML to generate the input object itself. It should not implement the surrounding table cells/rows, or labels/help messages.

Parameters
string$valueThe value to set the input to; eg a default text for a text input.
Returns
string Valid HTML.
HTMLFormField::getInputOOUI (   $value)

Same as getInputHTML, but returns an OOUI object. Defaults to false, which getOOUI will interpret as "use the HTML version"

Parameters
string$value
Returns
OOUI|false
HTMLFormField::getLabel ( )
Returns
string HTML
HTMLFormField::getLabelAlignOOUI ( )
protected

Get label alignment when generating field for OOUI.

Returns
string 'left', 'right', 'top' or 'inline'
HTMLFormField::getMessage (   $value)
protected

Turns a *-message parameter (which could be a MessageSpecifier, or a message name, or a name + parameters array) into a Message.

Parameters
mixed$value
Returns
Message
HTMLFormField::getNearestFieldByName (   $alldata,
  $name 
)
protected

Fetch a field value from $alldata for the closest field matching a given name.

This is complex because it needs to handle array fields like the user would expect. The general algorithm is to look for $name as a sibling of $this, then a sibling of $this's parent, and so on. Keeping in mind that $name itself might be referencing an array.

Parameters
array$alldata
string$name
Returns
string
HTMLFormField::getOOUI (   $value)

Get the OOUI version of the div. Falls back to getDiv by default.

Since
1.26
Parameters
string$valueThe value to set the input to.
Returns
OOUI|OOUI
HTMLFormField::getOptions ( )

Fetch the array of options from the field's parameters. In order, this checks 'options-messages', 'options', then 'options-message'.

Returns
array|null Options array
Todo:
This is copied from Xml::listDropDown(), deprecate/avoid duplication?
HTMLFormField::getOptionsOOUI ( )

Get options and make them into arrays suitable for OOUI.

Returns
array Options for inclusion in a select or whatever.
HTMLFormField::getRaw (   $value)

Get the complete raw fields for the input, including help text, labels, and whatever.

Since
1.20
Parameters
string$valueThe value to set the input to.
Returns
string Complete HTML table row.
HTMLFormField::getTableRow (   $value)

Get the complete table row for the input, including help text, labels, and whatever.

Parameters
string$valueThe value to set the input to.
Returns
string Complete HTML table row.
HTMLFormField::getTooltipAndAccessKey ( )

Returns the attributes required for the tooltip and accesskey.

Returns
array Attributes
HTMLFormField::getVForm (   $value)

Get the complete field for the input, including help text, labels, and whatever. Fall back from 'vform' to 'div' when not overridden.

Since
1.25
Parameters
string$valueThe value to set the input to.
Returns
string Complete HTML field.
HTMLFormField::hasVisibleOutput ( )

If this field has a user-visible output or not. If not, it will not be rendered

Returns
bool
HTMLFormField::isHidden (   $alldata)

Test whether this field is supposed to be hidden, based on the values of the other form fields.

Since
1.23
Parameters
array$alldataThe data collected from the form
Returns
bool
HTMLFormField::isHiddenRecurse ( array  $alldata,
array  $params 
)
protected

Helper function for isHidden to handle recursive data structures.

Parameters
array$alldata
array$params
Returns
bool
Exceptions
MWException
HTMLFormField::loadDataFromRequest (   $request)

Get the value that this input has been set to from a posted form, or the input's default value if it has not been set.

Parameters
WebRequest$request
Returns
string The value
HTMLFormField::msg ( )

Get a translated interface message

This is a wrapper around $this->mParent->msg() if $this->mParent is set and wfMessage() otherwise.

Parameters are the same as wfMessage().

Returns
Message
HTMLFormField::needsLabel ( )
protected

Should this field have a label, or is there no input element with the appropriate id for the label to point to?

Returns
bool True to output a label, false to suppress
HTMLFormField::setShowEmptyLabel (   $show)

Tell the field whether to generate a separate label element if its label is blank.

Since
1.22
Parameters
bool$showSet to false to not generate a label.
Returns
void
HTMLFormField::skipLoadData (   $request)

Skip this field when collecting data.

Parameters
WebRequest$request
Returns
bool
Since
1.27
HTMLFormField::validate (   $value,
  $alldata 
)

Override this function to add specific validation checks on the field input. Don't forget to call parent::validate() to ensure that the user-defined callback mValidationCallback is still run

Parameters
string | array$valueThe value the field was submitted with
array$alldataThe data collected from the form
Returns
bool|string True on success, or String error to display, or false to fail validation without displaying an error.

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