Valiant::HTML::FormBuilder::Checkbox - A custom formbuilder for checkbox content
$fb->collection_checkbox({person_roles => 'role_id'}, $roles, id=>'label', sub { my $fb_roles = shift; $fb_roles->checkbox({class=>'form-check-input'}); $fb_roles->label({class=>'form-check-label'}); });
This is a custom subclass of Valiant::HTML::FormBuilder that modifies the label and checkbox method so that it is already aware of the the field values, if its checked or not, etc. It also addes three methods, text which is the text value of the collection; value, which is its value and checked which is a boolean indicated if the checkbox is 'checked' or not.
label
checkbox
text
value
checked
Generally you use this inside a collection_checkbox when you want to have some custom HTML and attributes on the checkbox and label elements (typically for styling as in the example shown.
collection_checkbox
Chances are you won't use this stand alone but rather from inside a parent builder.
Valiant::HTML::FormBuilder
See Valiant
To install Valiant, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Valiant
CPAN shell
perl -MCPAN -e shell install Valiant
For more information on module installation, please visit the detailed CPAN module installation guide.