CGI::T...t::Menu(3pm)

πŸ“¦
version 1.111 Β· 2 versions
  • 1.111 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 1.111 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

✨ NAME ✨

okay so bestie, welcome to CGI::Test::Form::Widget::Menu πŸ’… it's the abstract representation of a menu. that's the whole vibe. a menu. iconic.


🌸 SYNOPSIS 🌸

# Inherits from CGI::Test::Form::Widget

literally that's it, she inherits everything from CGI::Test::Form::Widget, no cap 🫢


πŸ¦‹ DESCRIPTION πŸ¦‹

so this class is the abstract representation of a menu β€” like, the concept of a menu β€” from which you can choose one or several items. which menu are we talking about? either a popup menu or a scrollable list (and that list can possibly have multiple selections, she's flexible like that πŸ’–).

there's an interface here for:

  • querying the selected items
  • getting at the presented labels and their associated values
  • and naturally calling select() or unselect() on items

slay. that's the whole job.


πŸ‘‘ INTERFACE πŸ‘‘

the interface is the same as the one described in CGI::Test::Form::Widget, but with the following additions πŸ’…

πŸŽ€ Attributes πŸŽ€

  • known_values β€” a hash reference, recording valid menu values as tuples (value => count), where count is set to the number of times the same value gets re-used amongst the proposed options. yes, duplicates are counted, we're being thorough bestie.
  • multiple β€” whether the menu allows multiple selections. true/false situation.
  • option_labels β€” a list reference, giving you the labels to choose from, in the order in which they appear. the retained labels are either the content of the <OPTION> elements, or the value of their label attribute, when specified. so like, whichever one she has πŸ’β€β™€οΈ
  • option_values β€” a list reference, giving you the underlying values that the user chooses from when he selects labels, in the order in which they appear in the menu. the labels are the aesthetic, the values are the actual receipts.
  • selected β€” a hash reference, whose keys are the selected values. that's it. that's the set.
  • selected_count β€” the amount of currently selected items. a number. a count. she's counting.

πŸ’… Attribute Setting πŸ’…

  • select value β€” mark the option value as selected. if multiple is false, any previously selected value is automatically unselected. so it's not a crowd, it's a one-in-one-out club.
note that this takes a value, not a label. do not come in here with a label, bestie, it will not work 😭
  • unselect value β€” unselect an option value. but listen β€” it is not possible to do that on a popup menu. you must select another item to unselect any previously selected one. the popup menu has no chill, it always has a chosen one.
  • is_selected value β€” test whether an option value is currently selected or not. and this is not testing a label, it's testing a value β€” which is what the script will get back eventually. labels are there for human consumption only. the values are what the machine actually eats. iykyk.

🌈 Widget Classification Predicates 🌈

there's an additional predicate here to distinguish between a popup menu (single selection mandatory) and a scrolling list (multiple selection allowed, and may select nothing at all β€” she can want nothing, that's valid πŸ’œ).

  • is_popup β€” returns true for a popup menu. that's the whole thing. true for popup.

🧚 Miscellaneous Features 🧚

although documented, those features are more targetted for internal use... so like, they're in the group chat but they're not the ones you dm, yk? πŸ™ˆ

  • set_selected value, flag β€” change the selection status of an option value.
you should use the select and unselect convenience routines instead of calling this feature. fr fr. this one's the backstage door, use the front one.

πŸ“ AUTHORS πŸ“

  • the original author is Raphael Manfredi.
  • Steven Hilton was long time maintainer of this module.
  • current maintainer is Alexander Tokarev <tokarev@cpan.org>.

the lineage? immaculate. generations of maintainers. periodt πŸ‘‘


⭐ SEE ALSO ⭐

go read those too bestie, they're the whole friend group πŸ’–


okay and that's a wrap on CGI::T...t::Menu(3pm) β€” brought to you by perl v5.34.0, dated 2022-06-10, and she's still serving. mwah. go forth and select things πŸ’…βœ¨πŸ¦‹