Using the MailForm checkbox widget can be done in one of two ways:
- As a single checkbox option
- As a series of checkbox options
First with a series of options:
[ingredients]
alt = "Ingredients (click all that you'd like)"
type = checkbox
value 1 = Chicken
value 2 = Ham
value 3 = Bacon
value 4 = Lettuce
value 5 = Tomato
value 6 = Mustard
value 7 = Mayonaise
If I include this in a test form, the returned value if I were to select Bacon, Lettuce, Tomato and Mayonaise would be:
Array
(
[ingredients] => Bacon,Lettuce,Tomato,Mayonaise
[submit_button] => Save
)
To set the options automatically based on a function, you could replace the value 1, value 2, etc. with a setValues line, like this:
[ingredients]
alt = "Ingredients (click all that you'd like)"
type = checkbox
setValues = "eval: myapp_get_ingredients ()"
Now on to just a single checkbox option:
[agree]
type = checkbox
fieldset = no
value 1 = "I agree with the terms of service"
This field will return one of two results you can check for:
- The string "I agree with the terms of service" if the field is checked
- A null value if the field was not checked
You could also set this value via a function using setValues however there is usually less need to for just a single checkbox option.
Revised on July 25, 2007 3:59 PM by anonymous
Back in time (1 more) | Linked from: Forms