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

<forms:checkboxgroup> </...>

This control is intended to simplify the grouping of checkbox values.
Wrapping checkboxes in a group allows you to omit the name and validation attributes on individual checkboxes by applying them via name and validations attributes on the group.

Content

Must contain at least 1 checkbox tag.

Attributes

align
string
Align

Sets the alignment of checkboxes in the group.

Possible values: [Default] vertical, horizontal
id
string
(Required) Give this control a unique id. Can be accessed in the client DOM (eg, document.getElementById('myid') or in the server DOM using [? $myid ?] or [? $('myid') ?]).
name
string
Name

Sets the name value which will be applied to all child Checkboxes. For
Checkboxes, the name attribute indicates which form field they will submit their value to.

Note: Uses the same [ ] syntax as forms:checkbox

Eg: name="fruits[]"
validations
string
Validations

Sets the validations to be applied to child checkboxes as a comma separated string.

Eg: validations="mandatory"

When no validations attribute value is set, no item needs to be selected.

Examples

Grouping Checkboxes

The name of the checkbox group acts as the field to which the checkboxes will map. This is used instead of applying a name attribute to each individual checkbox.

HTML:

<forms:row label="Preferred Fruit"> <forms:checkboxgroup name="fruit[]" validations="mandatory"> <forms:checkbox valuechecked="apple" label="Apple" /> <forms:checkbox valuechecked="orange" label="Orange" /> <forms:checkbox valuechecked="pear" label="Pear" /> </forms:checkboxgroup> </forms:row>

Populate From Datasource

CheckBoxes can be repeated from a datasource using a repeater. Take care to ensure that any generated valuechecked attributes will be unique.

HTML:

<forms:checkboxgroup name="favourite_products[]" validations="mandatory"> <data:repeater datasource="\Components\Commerce\Products::getAll()" as="product"> <forms:checkbox valuechecked="[? $product['product_id'] ?]" label="[? $product['product_title'] ?]" /> </data:repeater> </forms:checkboxgroup>