MediaWiki  REL1_22
HTMLFormField Class Reference

The parent class to generate form fields. More...

Inheritance diagram for HTMLFormField:
Collaboration diagram for HTMLFormField:

List of all members.

Public Member Functions

 __construct ($params)
 Initialise the object.
 filter ($value, $alldata)
 getDefault ()
 getDiv ($value)
 Get the complete div for the input, including help text, labels, and whatever.
 getErrorsAndErrorClass ($value)
 Determine form errors to display and their classes.
 getHelpText ()
 Determine the help text to display.
 getHelpTextHtmlDiv ($helptext)
 Generate help text HTML in div format.
 getHelpTextHtmlRaw ($helptext)
 Generate help text HTML formatted for raw output.
 getHelpTextHtmlTable ($helptext)
 Generate help text HTML in table format.
 getInputHTML ($value)
 This function must be implemented to return the HTML to generate the input object itself.
 getLabel ()
 getLabelHtml ($cellAttributes=array())
 getRaw ($value)
 Get the complete raw fields for the input, including help text, labels, and whatever.
 getTableRow ($value)
 Get the complete table row for the input, including help text, labels, and whatever.
 getTooltipAndAccessKey ()
 Returns the attributes required for the tooltip and accesskey.
 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.
 msg ()
 Get a translated interface message.
 setShowEmptyLabel ($show)
 Tell the field whether to generate a separate label element if its label is blank.
 validate ($value, $alldata)
 Override this function to add specific validation checks on the field input.

Static Public Member Functions

static flattenOptions ($options)
 flatten an array of options to a single array, for instance, a set of "<options>" inside "<optgroups>".

Public Attributes

 $mParams
HTMLForm $mParent

Protected Member Functions

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

Static Protected Member Functions

static formatErrors ($errors)
 Formats one or more errors as accepted by field validation-callback.

Protected Attributes

 $mClass = ''
 $mDefault
 $mFilterCallback
 $mID
 $mLabel
 $mName
bool $mShowEmptyLabels = true
 If true will generate an empty div element with no label.
 $mValidationCallback

Detailed Description

The parent class to generate form fields.

Any field type should be a subclass of this.

Definition at line 1224 of file HTMLForm.php.


Constructor & Destructor Documentation

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

Reimplemented in HTMLButtonField, HTMLHiddenField, HTMLInfoField, HTMLSelectAndOtherField, HTMLSelectOrOtherField, HTMLCheckMatrix, and Licenses.

Definition at line 1347 of file HTMLForm.php.


Member Function Documentation

HTMLFormField::filter ( value,
alldata 
)

Definition at line 1296 of file HTMLForm.php.

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

Definition at line 1686 of file HTMLForm.php.

Referenced by Preferences\datetimePreferences(), Preferences\getOptionFromUser(), HTMLMultiSelectField\validate(), and HTMLRadioField\validate().

static HTMLFormField::formatErrors ( errors) [static, protected]

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

Parameters:
$errorsString|Message|Array of strings or Message instances
Returns:
String html
Since:
1.18

Definition at line 1706 of file HTMLForm.php.

Reimplemented in HTMLMultiSelectField, and HTMLCheckMatrix.

Definition at line 1659 of file HTMLForm.php.

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.

Reimplemented in HTMLApiField, HTMLEditTools, HTMLHiddenField, and HTMLInfoField.

Definition at line 1471 of file HTMLForm.php.

Determine form errors to display and their classes.

Since:
1.20
Parameters:
string$valuethe value of the input
Returns:
Array

Definition at line 1605 of file HTMLForm.php.

Determine the help text to display.

Since:
1.20
Returns:
String

Definition at line 1571 of file HTMLForm.php.

References $name, array(), as, and msg().

Generate help text HTML in div format.

Since:
1.20
Parameters:
$helptextString|null
Returns:
String

Definition at line 1547 of file HTMLForm.php.

Generate help text HTML formatted for raw output.

Since:
1.20
Parameters:
$helptextString|null
Returns:
String

Definition at line 1562 of file HTMLForm.php.

Generate help text HTML in table format.

Since:
1.20
Parameters:
$helptextString|null
Returns:
String

Definition at line 1527 of file HTMLForm.php.

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.

Reimplemented in HTMLApiField, HTMLEditTools, HTMLButtonField, HTMLHiddenField, HTMLInfoField, HTMLRadioField, HTMLSelectAndOtherField, HTMLMultiSelectField, HTMLSelectOrOtherField, HTMLSelectField, HTMLCheckMatrix, HTMLCheckField, HTMLTextAreaField, HTMLTextField, and Licenses.

Reimplemented in HTMLCheckField.

Definition at line 1618 of file HTMLForm.php.

HTMLFormField::getLabelHtml ( cellAttributes = array())

Reimplemented in UploadSourceField.

Definition at line 1622 of file HTMLForm.php.

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.

Reimplemented in HTMLApiField, HTMLEditTools, HTMLHiddenField, and HTMLInfoField.

Definition at line 1507 of file HTMLForm.php.

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.

Reimplemented in HTMLApiField, HTMLEditTools, HTMLHiddenField, HTMLInfoField, and HTMLCheckMatrix.

Definition at line 1427 of file HTMLForm.php.

Returns the attributes required for the tooltip and accesskey.

Returns:
array Attributes

Definition at line 1672 of file HTMLForm.php.

References array(), empty, and Linker\tooltipAndAccesskeyAttribs().

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:
$requestWebRequest
Returns:
String the value

Reimplemented in HTMLSelectAndOtherField, HTMLMultiSelectField, HTMLSelectOrOtherField, HTMLCheckMatrix, and HTMLCheckField.

Definition at line 1332 of file HTMLForm.php.

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 object

Definition at line 1264 of file HTMLForm.php.

Referenced by getHelpText(), and HTMLRadioField\validate().

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

Reimplemented in HTMLButtonField, HTMLInfoField, HTMLRadioField, HTMLMultiSelectField, and HTMLCheckField.

Definition at line 1310 of file HTMLForm.php.

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

Definition at line 1322 of file HTMLForm.php.

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$valuethe value the field was submitted with
array$alldatathe data collected from the form
Returns:
Mixed Bool true on success, or String error to display.

Reimplemented in HTMLButtonField, HTMLRadioField, HTMLSelectAndOtherField, HTMLMultiSelectField, HTMLSelectField, HTMLCheckMatrix, HTMLIntField, HTMLFloatField, EditWatchlistCheckboxSeriesField, and HTMLBlockedUsersItemSelect.

Definition at line 1284 of file HTMLForm.php.

Referenced by HtmlCheckMatrixTest\validate().


Member Data Documentation

HTMLFormField::$mClass = '' [protected]

Definition at line 1232 of file HTMLForm.php.

HTMLFormField::$mDefault [protected]

Definition at line 1233 of file HTMLForm.php.

HTMLFormField::$mFilterCallback [protected]

Definition at line 1227 of file HTMLForm.php.

HTMLFormField::$mID [protected]

Definition at line 1231 of file HTMLForm.php.

HTMLFormField::$mLabel [protected]

Definition at line 1230 of file HTMLForm.php.

HTMLFormField::$mName [protected]

Definition at line 1228 of file HTMLForm.php.

HTMLFormField::$mParams

Definition at line 1229 of file HTMLForm.php.

HTMLForm HTMLFormField::$mParent

Definition at line 1242 of file HTMLForm.php.

bool HTMLFormField::$mShowEmptyLabels = true [protected]

If true will generate an empty div element with no label.

Since:
1.22

Definition at line 1238 of file HTMLForm.php.

HTMLFormField::$mValidationCallback [protected]

Definition at line 1226 of file HTMLForm.php.


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