Valiant::HTML::FormBuilder::RadioButton - A custom formbuilder for radio button content
$fb_profile->collection_radio_buttons('state_id', $states, id=>'name', +{ errors_classes=>'is-invalid'}, sub ( my $fb_state = shift; $fb_state->radio_button(+{class=>"form-check-input"}); $fb_state->label(+{class=>"form-check-label"}); });
This is a custom subclass of Valiant::HTML::FormBuilder that modifies the label and radio_button 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
radio_button
text
value
checked
Generally you use this inside a collection_radio_button when you want to have some custom HTML and attributes on the radio button and label elements (typically for styling as in the example shown.
collection_radio_button
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.