Checkbox group

Checkbox group renders a set of checkboxes.

v0.36.1AlphaNot reviewed for accessibility
Forms frameworkThe CheckBoxGroup component is part of the Primer forms framework. If you're building a form, please consider using the framework instead of this standalone component.

Description

Check box groups consist of one or more related check boxes.

Arguments

NameTypeDefaultDescription
name
String

N/A

Value for the HTML name attribute. When provided, the check box values will be submitted in to the server in :array mode. See the CheckBox for more information.

label
String

N/A

Label text displayed above the input.

hidden
Boolean

N/A

When set to true, visually hides the group.

caption
String

N/A

A string describing the field and what sorts of input it expects. Displayed below the group.

invalid
Boolean

N/A

If set to true, the input will be marked as invalid. Implied if validation_message is truthy. This option is set to true automatically if the model object associated with the form reports that the input is invalid via Rails validations. It is provided for cases where the form does not have an associated model. If the input is invalid as determined by Rails validations, setting invalid to false will have no effect.

validation_message
String

N/A

A string displayed between the caption and the input indicating the input's contents are invalid. This option is, by default, set to the first Rails validation message for the input (assuming the form is associated with a model object). Use validation_message to override the default or to provide a validation message in case there is no associated model object.

label_arguments
Hash

N/A

Attributes that will be passed to Rails' builder.label method. These can be HTML attributes or any of the other label options Rails supports. They will appear as HTML attributes on the <label> tag.

Examples

Methods

check_box(system_arguments: Hash, block: Proc)

Adds a check box to the group.

Parameters

NameTypeDefaultDescription
system_arguments
Hash

N/A

The arguments accepted by CheckBox.

block
Proc

N/A

The block accepted by CheckBox.