Fork me on GitHub

Nibble Development

Nibble Development

PHP classes and libraries for developers

Checkbox field

The Nibble forms checkbox fields are created in a way that is very similar to the radio button fields. In fact the first three arguments are identical, the way the validation works is different to allow for multiple answers but as this is automatic, no difference is made to the PHP class call. Therefore, just like a radio button field, the simplest checkbox field only requires two arguments. Note that the PHP class is “Checkbox” not “Radio”:

Minimum selected: The fourth argument differs from the radio button field. This argument specifies how many options the user must select in order for the field to validate. The argument is supplied as an integer and can be false if no minimum is required, however the is little point to setting it to false due to the “required” argument before and as below, the default value is already false (i.e only add this argument if at least two values are required).

Note that like radio button fields, checkbox options can have custom or automatic keys, or a mixture of the two types. A full example of a checkbox with all arguments could look like:

Luke Rotherfield

Freelance PHP Developer
is a PHP developer dedicated to writing the most awesome liraries for his fellow devs :) enjoy

Latest posts by Luke Rotherfield (see all)

Leave a Comment