-
Notifications
You must be signed in to change notification settings - Fork 14
How to create radio buttons using the radio button function
Added for version: 0.4
You want to allow the user to select from a set of radio buttons? Use the radio-button function.
The radio-button function takes a record, the name of the record, the key in the record to use to determine if the radio button is selected, and the value of the radio button.
If you have a record called :frog with key :color of value “red”, you can create a radio button to select the color value with:
(radio-button { :color "red" } :frog :color "red")
The above will create one radio button with value “red” which will be selected.
Let’s assume the symbol for the record is frog-record and create multiple radio buttons:
(radio-button frog-record :frog :color "red") (radio-button frog-record :frog :color "green") (radio-button frog-record :frog :color "yellow")
In the above code, all of the radio buttons will be linked since they have the same record-name and key-name. each has a different value. Assuming frog-record is { :color “red” } only the first radio button will be selected.
If you want to set other attributes of the radio-button you can pass html-options as the last parameter.
To set the id of the original radio button use:
(radio-button { :color "red" } :frog :color "red" { :id "redcolor" })