Skip to content

How to create check boxes using the check box function

macourtney edited this page Sep 13, 2010 · 2 revisions

Added for version: 0.4

Use the check-box function to create check boxes on your form.

The check-box function takes a record, the name of the record, a key in the record to get the value from, and optional html-options, checked-value and unchecked-value.

Check-box assumes the value you’re setting in the record is number with value 0 for unchecked and 1 for checked. Therefore, you don’t have to set the value.

To create a check box for :is-active on record :foo use:

(check-box { :is-active 0 } :foo :is-active)

You can pass in html-options to set the id of the check box:

(check-box { :is-active 0 } :foo :is-active { :id "is-active" })

To set the checked value to something other than 1, you can pass it at the fifth argument:

(check-box { :is-active 0 } :foo :is-active {} "active")

To set the unchecked value to something other than 0, pass the unchecked value as the sixth argument:

(check-box { :is-active "inactive" } :foo :is-active {} "active" "inactive")
Clone this wiki locally