<forms:radiobutton>
AJAX
Data
Forms
ATTRIBUTES
EXAMPLES
Layout
Logic
Navigation
Personalisation
Standard
Templates
Regions
Third Party

<forms:radiobutton />

Radio buttons allow the user to choose one value from a set of options.
Radio buttons that share the same name, are considered part of the same group.

Attributes

allowUncheck
bool
Allows the radiobutton to be unchecked.
autoFocus
bool
Auto Focus

If true, this control will attempt to focus itself after the page has loaded. Note that only one element may be focused on the page at a time.
Default = false
dataColumn
Sets the data column

The datacolumn links the form item to a key used when getting or saving from a component (as defined by the parent form).
disabled
bool
Disable Input

Disables the input, preventing user interaction
height
string
Height

Sets the height of the element. The default units are pixels. include the percentage symbol % to user percentage values.
id
string
(Required) Most form items need a unique id so that they can submit data to the server. No two form items may have the same id. For situations where multiple form items submit to the same field, see the name attribute. Id's that begin with contact_ will automatically save Contact information to the Contact database as long as the user has entered enough identifying information (ideally Name and Email). Check the Contact Fields page for correct field names.
label
bool
Label text that appears to the right of the button.
name
string
Pick a name unique within the parent form.
Radio buttons that share the same name are considered part of the same group.
noContainer
bool
Set to true if you need a simple <input type="radio"> without any container elements
saveState
bool
Restore state on reload

Whether the value of the input persists when the page is revisited.
Default = false
transformations
Value Transformations

Sets the value transformations to be applied to the value of the form item as a comma separated string.
validations
Validations

Sets the validations to be applied to the value of the form item as a comma separated string.

Eg: validations="mandatory"

When no validations attribute value is set, the form item is optional.
valueChecked
string
The value to send with the form, when this particular radio button is checked. All radio buttons in the same group (sharing the same name), should have different values for valuechecked.
width
string
Width

Sets the width of the element. The default units are pixels. include the percentage symbol % to user percentage values.

Examples

Multiple Radiobuttons of Same Name

Demonstrates multiple checkboxes mapped to the same name.

HTML:

<forms:row label="Preferred Fruit"> <forms:radiobutton name="fruit" id="fruit_apple" valuechecked="apple" label="Apple" value="apple" /><br /> <forms:radiobutton name="fruit" id="fruit_orange" valuechecked="orange" label="Orange" /><br /> <forms:radiobutton name="fruit" id="fruit_pear" valuechecked="pear" label="Pear" /> </forms:row>

Run Example

Radio Buttons and Ajax

Demonstrates using radio buttons in combination with Ajax.

HTML:

<forms:form id="my_form"> <forms:row label="Preferred Fruit"> <ajax:event id="fruit_ajaxevent" updateregions="fruit_ajaxregion" /> <forms:radiobutton name="fruit" id="fruit_apple" valuechecked="apple" label="Apple" onchangeajax="fruit_ajaxevent" value="a" /><br /> <forms:radiobutton name="fruit" id="fruit_orange" valuechecked="orange" label="Orange" onchangeajax="fruit_ajaxevent" /><br /> <forms:radiobutton name="fruit" id="fruit_pear" valuechecked="pear" label="Pear" onchangeajax="fruit_ajaxevent" /> </forms:row> </forms:form> <ajax:region id="fruit_ajaxregion"> <strong>Was apple checked?</strong> [? varDump($fruit_apple.checked) ?] <logic:if test="$fruit_apple.checked"> Yes! </logic:if> <logic:else> No! </logic:else> <br /> <br /> <strong>Value of form item with name 'fruit':</strong><br /> [? $my_form.getValueForFormItem('fruit') ?] </ajax:region>

Run Example