HTML::FormFu::Role::Element::Group - Role for grouped form fields
Base class for HTML::FormFu::Element::Checkboxgroup, HTML::FormFu::Element::Radiogroup, and HTML::FormFu::Element::Select fields.
Arguments: none
Arguments: \@options
--- elements: - type: Select name: foo options: - [ 01, January ] - [ 02, February ] - value: 03 label: March attributes: style: highlighted - [ 04, April ]
If passed no arguments, it returns an arrayref of the currently set options.
Use to set the list of items in the select menu / radiogroup.
Its arguments must be an array-ref of items. Each item may be an array ref of the form [ $value, $label ] or a hash-ref of the form { value => $value, label => $label }. Each hash-ref may also have an attributes key.
[ $value, $label ]
{ value => $value, label => $label }
attributes
Passing an item containing a group key will, for Select fields, create an optgroup. And for Radiogroup fields or Checkboxgroup fields, create a sub-group of radiobuttons or checkboxes with a new span block, with the classname subgroup.
group
span
subgroup
An example of Select optgroups:
--- elements: - type: Select name: foo options: - label: "group 1" group: - [1a, 'item 1a'] - [1b, 'item 1b'] - label: "group 2" group: - [2a, 'item 2a'] - [2b, 'item 2b']
When using the hash-ref construct, the label_xml and label_loc variants of label are supported, as are the value_xml and value_loc variants of value, the attributes_xml variant of attributes and the label_attributes_xml variant of label_attributes.
label_xml
label_loc
label
value_xml
value_loc
value
attributes_xml
label_attributes_xml
label_attributes
container_attributes or container_attributes_xml is used by HTML::FormFu::Element::Checkboxgroup and HTML::FormFu::Element::Radiogroup for the c<span> surrounding each item's input and label. It is ignored by HTML::FormFu::Element::Select elements.
container_attributes
container_attributes_xml
label_attributes / label_attributes_xml is used by HTML::FormFu::Element::Checkboxgroup and HTML::FormFu::Element::Radiogroup for the c<label> tag of each item. It is ignored by HTML::FormFu::Element::Select elements.
Arguments: \@values
--- elements: - type: Radiogroup name: foo values: - jan - feb - mar - apr
A more concise alternative to "options". Use to set the list of values in the select menu / radiogroup.
Its arguments must be an array-ref of values. The labels used are the result of ucfirst($value).
ucfirst($value)
--- elements: - type: Select name: foo value_range: - "" - 1 - 12
Similar to "values", but the last 2 values are expanded to a range. Any preceding values are used literally, allowing the common empty first item in select menus.
If true, then a blank option will be inserted at the start of the option list (regardless of whether "options", "values" or "value_range" was used to populate the options). See also "empty_first_label".
If "empty_first" is true, and "empty_first_label" is set, this value will be used as the label for the first option - so only the first option's value will be empty.
Is a sub-class of, and inherits methods from HTML::FormFu::Role::Element::Field, HTML::FormFu::Element
HTML::FormFu
Carl Franks, cfranks@cpan.org
cfranks@cpan.org
This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself.
To install HTML::FormFu, copy and paste the appropriate command in to your terminal.
cpanm
cpanm HTML::FormFu
CPAN shell
perl -MCPAN -e shell install HTML::FormFu
For more information on module installation, please visit the detailed CPAN module installation guide.