module CGI::HtmlExtension
def checkbox_group(name = "", *values)
checkbox_group("NAME" => "name",
"VALUES" => [["foo"], ["bar", true], "baz"])
checkbox_group("NAME" => "name",
"VALUES" => ["foo", "bar", "baz"])
checkbox_group("NAME" => "name",
# Baz
# Bar
# Foo
checkbox_group("name", ["1", "Foo"], ["2", "Bar", true], "Baz")
# baz
# bar
# foo
checkbox_group("name", ["foo"], ["bar", true], "baz")
# baz
# bar
# foo
checkbox_group("name", "foo", "bar", "baz")
(defaults to false).
to the same as the label), or the boolean checked element
array, by omitting either the value element (defaults
Each value can also be specified as a two-element
checkbox is CHECKED.
label; and the third is a boolean specifying whether this
The first element is the VALUE attribute; the second is the
Each value can also be specified as a three-element array.
same effect.
for that checkbox. A single-element array has the
as the value of the VALUE attribute and as the label
can be specified as a String, which will be used both
There will be one checkbox for each value. Each value
Each checkbox is followed by a label.
The checkboxes will all have the same +name+ attribute.
Generate a sequence of checkbox elements, as a String.
def checkbox_group(name = "", *values) if name.kind_of?(Hash) values = name["VALUES"] name = name["NAME"] end values.collect{|value| if value.kind_of?(String) checkbox(name, value) + value else if value[-1] == true || value[-1] == false checkbox(name, value[0], value[-1]) + value[-2] else checkbox(name, value[0]) + value[-1] end end }.join end