Template:Form calculator field

From Brighter Shores Wiki
Jump to navigation Jump to search
Template documentation
This documentation is transcluded from Template:Form calculator field/doc. [edit] [history] [purge]

This template is for creating form calculators in a standardised way, used with Template:Form calculator. This implements the syntax of Brighter Shores:Calculators/Form calculators as a template.

Usage

{{Form calculator
|page = name of the page the calculator is on: use {{subst:FULLPAGENAME}}
|cat = set to no to remove category
|template = the form's template to call
|form = unique id for the form
|result = unique id for the result
|outputtype = type of output
|forminit = intial text in the form area
|resultinit = initial text in the result area
|field1 ={{Form calculator field
|param = name of the first parameter
|label = label for parameter 1
|default = default value for parameter 1
|type = type of parameter 1
|range = range of parameter 1
}}
...
|fieldX ={{Form calculator field
|param = name of the Xth parameter
|label = label for parameter X
|default = default value for parameter X
|type = type of parameter X
|range = range of parameter X
}}
}}
}}

About

Any number of parameters can be defined. Each parameter defines a row in the form, and has 7 components:

  • param
  • label
  • default
  • type
  • range
  • toggles
  • help

Template data

Show/hide template's data

The following information is used by extensions and applications, such as VisualEditor, to help users implement this template onto pages. Please ensure that it is up-to-date.

This template is for creating form calculators in a standardised way, used with [[Template:Form calculator]].

Template parameters[Edit template data]

This template prefers block formatting of parameters.

ParameterDescriptionTypeStatus
Parameter Nameparam

This is the name of the parameter which will be passed to the template when submitted.

Stringrequired
Labellabel

The [user-friendly] label to display in the form. The label can contain most normal wikitext: links, images, spans with styles and titles (hover-overs), etc.

Default
{{{param}}}
Linesuggested
Typetype

The type of input for this param. This can be used to restrict user input, or change the input field to a different type.

Suggested values
string group article number int select buttonselect combobox check toggleswitch togglebutton hs rsn fixed hidden semihidden
Default
string
Example
string
Text input field, no restriction.
group
Used to group other inputs together.
article
Text input field, no restrictions. Enables autocomplete for this field, based on the `suggestns` parameter.
number
Numbers. Text input field, set to number. Will prevent non-numbers being submitted.
int
Integers. Text input field, set to number. Will prevent non-integers being submitted.
select
Drop-down menu generated from the corresponding range parameter.
buttonselect
A series of buttons for selecting an option (only 1 selected at a time).
combobox
Text input with a drop-down menu that automatically filters a dropdown list generated from the range parameter.
check
Checkbox for submitting a boolean choice.
toggleswitch
Same function as checkbox but is a toggle instead.
togglebutton
Same function as checkbox but is a button (toggles on/off).
hs
Text input field, no restriction. Generates a lookup button to get data from hiscores, and updates the other fields as defined by the range parameter.
rsn
A special field for player names (when used by the calculator and not to populate another field).
fixed
The default value provided is shown but cannot be changed. Can be used as a separator or for in-form notes.
hidden
The default value provided is hidden from the form entirely. Used to pass things to the template that shouldn't be seen or changed by the user.
semihidden
The default value provided is hidden in the form, but still present in the HTML. This is for inter-script usage.
Stringsuggested
Rangerange

The range for the parameter, or any other configuration.

Stringoptional
Default Valuedefault

The default value for the parameter in the form. This is pre-filled into the form when loaded.

Default
string, article
Defaults to empty.
number, int
Defaults to empty. Should respect the range given.
select, buttonselect, combobox
One of the options given in the range.
check
Unticked by default. Will be ticked by default if defined as “true” or the same as “value if true” in the range.
fixed, hidden, semihidden
Can't be changed away from.
Stringoptional
Togglestoggles

The inputs or groups of inputs toggled by this widget. Applies to select, buttonselect, combobox, check, toggleswitch, togglebutton, int and number param types. Toggles are given in the format `value=toggles`. Note that when an option is chosen, all the groups/fields listed for other options (that aren't listed on the selected option) will be hidden.

Stringoptional
Help Texthelp

Help text for the form field. If text is Defaults to displaying an (i) icon that can be clicked to display the help.

Contentoptional