Template:Form calculator field/doc: Difference between revisions

From Brighter Shores Wiki
Jump to navigation Jump to search
Content added Content deleted
(Copied from https://runescape.wiki/w/Template:Form_calculator_field/doc?oldid=36071890 (See there for attribution))
 
(-RuneScape)
 
Line 1: Line 1:
{{documentation}}
{{documentation}}
This template is for creating form calculators in a standardised way, used with [[Template:Form calculator]]. This implements the syntax of [[RuneScape:Calculators/Form calculators]] as a template.
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==
==Usage==
Line 94: Line 94:
"label": "Default Value",
"label": "Default Value",
"description": "The default value for the parameter in the form. This is pre-filled into the form when loaded.",
"description": "The default value for the parameter in the form. This is pre-filled into the form when loaded.",
"default": "\n; string, article : Defaults to empty.\n; number, int : Defaults to empty. Should respect the range given.\n; select, buttonselect, combobox : One of the options given in the range.\n; check : Unticked by default. Will be ticked by default if defined as “true” or the same as “value if true” in the range.\n; hs, rsn : If left blank, tries to use the RuneScape name entered elsewhere on the wiki.\n; fixed, hidden, semihidden : Can't be changed away from.\n",
"default": "\n; string, article : Defaults to empty.\n; number, int : Defaults to empty. Should respect the range given.\n; select, buttonselect, combobox : One of the options given in the range.\n; check : Unticked by default. Will be ticked by default if defined as “true” or the same as “value if true” in the range.\n; fixed, hidden, semihidden : Can't be changed away from.\n",
"type": "string"
"type": "string"
},
},

Latest revision as of 19:52, 19 December 2024

This is a documentation subpage for Template:Form calculator field.
It contains usage information, categories, and other content that is not part of the original template page.

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

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