HTML::...:Group(3pm)

πŸ“¦
version 2.07000 Β· 5 versions
, in debian bookworm, ubuntu jammy, ubuntu noble

πŸ’– HTML::FormFu::Role::Element::Group πŸ’–

okay bestie, welcome to the HTML::...:Group(3pm) page from the User Contributed Perl Documentation ✨ this is the whole thing, no skips, and it's lowkey giving "quietly holds the entire group of form fields together" energy. sit down, grab a strawberry πŸ“, let's go.


🌸 NAME 🌸

HTML::FormFu::Role::Element::Group β€” the Role for grouped form fields. it's a role, not a class, she's vibes only πŸ’…


⭐ VERSION ⭐

version 2.07


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so this is the base class for HTML::FormFu::Element::Checkboxgroup, HTML::FormFu::Element::Radiogroup, and HTML::FormFu::Element::Select fields. the three of them are literally sharing a brain and that brain is this role. main character energy, fr fr πŸ‘‘


πŸ’… METHODS πŸ’…

✨ options ✨

Arguments: none

Arguments: \@options

---
elements:
  - type: Select
    name: foo
    options:
      - [ 01, January ]
      - [ 02, February ]
      - value: 03
        label: March
        attributes:
          style: highlighted
      - [ 04, April ]

so! if you pass it no arguments, it hands you back an arrayref of the options that are currently set. no notes, just receipts 🧾

use it to set the list of items in the select menu / radiogroup.

its arguments must be an array-ref of items. each item can be either:

  • an array ref shaped like [ $value, $label ], or
  • a hash-ref shaped like { value => $value, label => $label }

and each hash-ref may also carry an attributes key. obsessed.

if you pass an item that contains a group key, then:

  • for Select fields, it creates an optgroup πŸŽ€
  • for Radiogroup fields or Checkboxgroup fields, it creates a sub-group of radiobuttons or checkboxes with a new span block, with the classname subgroup

an example of Select optgroups, pls enjoy:

---
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 you're 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. so many little variants, she contains multitudes.

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. (Select said "not my problem" πŸ™ˆ)

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 also ignored by HTML::FormFu::Element::Select elements. same vibe, same shrug πŸ’€

🌈 values 🌈

Arguments: \@values

---
elements:
  - type: Radiogroup
    name: foo
    values:
      - jan
      - feb
      - mar
      - apr

a more concise alternative to options. use it to set the list of values in the select menu / radiogroup. it's the "I don't have time for the whole thing" version and honestly? slay.

its arguments must be an array-ref of values. the labels used are the result of ucfirst($value). that's it, that's the whole trick ✨

🧚 value_range 🧚

Arguments: \@values

---
elements:
  - type: Select
    name: foo
    value_range:
      - ""
      - 1
      - 12

similar to values, but the last 2 values get expanded to a range πŸ”₯ any preceding values are used literally, which lets you do the super common empty first item in select menus. iconic behaviour tbh.

πŸŽ€ empty_first πŸŽ€

if true, then a blank option will be inserted at the start of the option list β€” and yes, regardless of whether options, values or value_range was used to populate the options. see also empty_first_label.

πŸ“ empty_first_label πŸ“

πŸ“ empty_first_label_xml πŸ“

πŸ“ empty_first_label_loc πŸ“

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. sneaky, clever, we love her πŸ’œ


πŸ‘‘ SEE ALSO πŸ‘‘

is a sub-class of, and inherits methods from HTML::FormFu::Role::Element::Field, HTML::FormFu::Element

HTML::FormFu


πŸ’– AUTHOR πŸ’–

Carl Franks, cfranks@cpan.org


⭐ LICENSE ⭐

this library is free software, you can redistribute it and/or modify it under the same terms as Perl itself.


πŸ¦‹ AUTHOR πŸ¦‹

Carl Franks <cpan@fireartist.com>


this software is copyright (c) 2018 by Carl Franks.

this is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.


okay that's the whole page bestie, no cap, every last detail preserved 🫢 and for the cute sign-off: this one's running on perl v5.28.1 and the page is dated 2019-01-12 β€” she's a little vintage, she's still that girl, periodt πŸ’…βœ¨πŸŒˆ

πŸ“¦ where this page comes from