MediaWiki
REL1_24
|
A container for HTMLFormFields that allows for multiple copies of the set of fields to be displayed to and entered by the user. More...
Public Member Functions | |
__construct ($params) | |
Initialise the object. | |
cancelSubmit ($values, $alldata) | |
Override this function if the control can somehow trigger a form submission that shouldn't actually submit the HTMLForm. | |
getDefault () | |
getInputHTML ($values) | |
This function must be implemented to return the HTML to generate the input object itself. | |
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. | |
validate ($values, $alldata) | |
Override this function to add specific validation checks on the field input. | |
Protected Member Functions | |
createFieldsForKey ($key) | |
Create the HTMLFormFields that go inside this element, using the specified key. | |
getInputHTMLForKey ($key, $values) | |
Get the input HTML for the specified key. | |
needsLabel () | |
Should this field have a label, or is there no input element with the appropriate id for the label to point to? | |
rekeyValuesArray ($key, $values) | |
Re-key the specified values array to match the names applied by createFieldsForKey(). | |
Protected Attributes | |
string | $uniqueId |
String uniquely identifying this cloner instance and unlikely to exist otherwise in the generated HTML, while still being valid as part of an HTML id. | |
Static Private Attributes | |
static | $counter = 0 |
A container for HTMLFormFields that allows for multiple copies of the set of fields to be displayed to and entered by the user.
Recognized parameters, besides the general ones, include: fields - HTMLFormField descriptors for the subfields this cloner manages. The format is just like for the HTMLForm. A field with key 'delete' is special: it must have type = submit and will serve to delete the group of fields. required - If specified, at least one group of fields must be submitted. format - HTMLForm display format to use when displaying the subfields: 'table', 'div', or 'raw'. row-legend - If non-empty, each group of subfields will be enclosed in a fieldset. The value is the name of a message key to use as the legend. create-button-message - Message key to use as the text of the button to add an additional group of fields. delete-button-message - Message key to use as the text of automatically- generated 'delete' button. Ignored if 'delete' is included in 'fields'.
In the generated HTML, the subfields will be named along the lines of "clonerName[index][fieldname]", with ids "clonerId--index--fieldid". 'index' may be a number or an arbitrary string, and may likely change when the page is resubmitted. Cloners may be nested, resulting in field names along the lines of "cloner1Name[index1][cloner2Name][index2][fieldname]" and corresponding ids.
Use of cloner may result in submissions of the page that are not submissions of the HTMLForm, when non-JavaScript clients use the create or remove buttons.
The result is an array, with values being arrays mapping subfield names to their values. On non-HTMLForm-submission page loads, there may also be additional (string) keys present with other types of values.
Definition at line 38 of file HTMLFormFieldCloner.php.
HTMLFormFieldCloner::__construct | ( | $ | params | ) |
Initialise the object.
array | $params | Associative Array. See HTMLForm doc for syntax. |
MWException |
Reimplemented from HTMLFormField.
Definition at line 47 of file HTMLFormFieldCloner.php.
HTMLFormFieldCloner::cancelSubmit | ( | $ | value, |
$ | alldata | ||
) |
Override this function if the control can somehow trigger a form submission that shouldn't actually submit the HTMLForm.
string | array | $value | The value the field was submitted with |
array | $alldata | The data collected from the form |
Reimplemented from HTMLFormField.
Definition at line 202 of file HTMLFormFieldCloner.php.
References $key, $value, as, createFieldsForKey(), and empty.
HTMLFormFieldCloner::createFieldsForKey | ( | $ | key | ) | [protected] |
Create the HTMLFormFields that go inside this element, using the specified key.
string | $key | Array key under which these fields should be named |
Definition at line 84 of file HTMLFormFieldCloner.php.
Referenced by cancelSubmit(), getDefault(), loadDataFromRequest(), and validate().
Reimplemented from HTMLFormField.
Definition at line 181 of file HTMLFormFieldCloner.php.
References $ret, array(), as, createFieldsForKey(), and empty.
Referenced by loadDataFromRequest().
HTMLFormFieldCloner::getInputHTML | ( | $ | value | ) |
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.
string | $value | The value to set the input to; eg a default text for a text input. |
Reimplemented from HTMLFormField.
Definition at line 345 of file HTMLFormFieldCloner.php.
References $html, $key, $name, $value, array(), as, Sanitizer\escapeId(), getInputHTMLForKey(), HTMLForm\loadInputFromParameters(), HTMLFormField\msg(), Html\rawElement(), and text.
HTMLFormFieldCloner::getInputHTMLForKey | ( | $ | key, |
$ | values | ||
) | [protected] |
Get the input HTML for the specified key.
string | $key | Array key under which the fields should be named |
array | $values |
Definition at line 260 of file HTMLFormFieldCloner.php.
Referenced by getInputHTML().
HTMLFormFieldCloner::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.
WebRequest | $request |
Reimplemented from HTMLFormField.
Definition at line 126 of file HTMLFormFieldCloner.php.
References $key, $ret, $value, array(), as, createFieldsForKey(), empty, getDefault(), and rekeyValuesArray().
HTMLFormFieldCloner::needsLabel | ( | ) | [protected] |
Should this field have a label, or is there no input element with the appropriate id for the label to point to?
Reimplemented from HTMLFormField.
Definition at line 122 of file HTMLFormFieldCloner.php.
HTMLFormFieldCloner::rekeyValuesArray | ( | $ | key, |
$ | values | ||
) | [protected] |
Re-key the specified values array to match the names applied by createFieldsForKey().
string | $key | Array key under which these fields should be named |
array | $values | Values array from the request |
Definition at line 113 of file HTMLFormFieldCloner.php.
Referenced by loadDataFromRequest().
HTMLFormFieldCloner::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
string | array | $value | The value the field was submitted with |
array | $alldata | The data collected from the form |
Reimplemented from HTMLFormField.
Definition at line 222 of file HTMLFormFieldCloner.php.
References $key, $ok, $value, as, createFieldsForKey(), empty, and HTMLFormField\msg().
HTMLFormFieldCloner::$counter = 0 [static, private] |
Definition at line 39 of file HTMLFormFieldCloner.php.
string HTMLFormFieldCloner::$uniqueId [protected] |
String uniquely identifying this cloner instance and unlikely to exist otherwise in the generated HTML, while still being valid as part of an HTML id.
Definition at line 45 of file HTMLFormFieldCloner.php.