HTML::...:Select(3pm)

πŸ“¦
version 1.11 Β· 3 versions
, in debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– HTML::Widget::Element::Select πŸ’–

okay bestie, so this is HTML::Widget::Element::Select β€” the Select Element from HTML::Widget. yes, the drop-down / list-box one. she's iconic, she's got range, and she has ✨opinions✨ about how you render her. let's get into it πŸŽ€


✨ SYNOPSIS ✨

my $e = $widget->element( 'Select', 'foo' );
$e->comment('(Required)');
$e->label('Foo');
$e->size(23);
$e->options( foo => 'Foo', bar => 'Bar' );
$e->selected(qw/foo bar/);
$e->constrain_options(1);

look at her. literally six lines and she's doing the most. slay 🫢


🌸 DESCRIPTION 🌸

Select Element. that's the whole vibe. πŸ’…

BUT β€” and this is the part you need to remember, no cap β€” as of version 1.09, an In constraint is no longer automatically added to Select elements. it used to be automatic, and now it's not. so if you want that functionality back, you go get it yourself with constrain_options. the old auto-magic is gone, bestie, you gotta ask nicely now πŸ™ˆ


πŸ¦‹ METHODS πŸ¦‹

πŸŽ€ comment

Add a comment to this Element's label. lil annotation moment. πŸ’¬

πŸŽ€ label

This label will be placed next to your Element. so like, the text sitting pretty right beside your select. ✨

πŸŽ€ size

If set to 1, the select element is displayed as a pop-up menu, otherwise the element is displayed as a list box, with the size determining the display height in rows.

the default size is 1. so yeah, by default she's a pop-up menu. surprise! πŸ‘‘

πŸŽ€ multiple

$widget->element( 'Select', 'foo' )->multiple( 1 );

If the multiple attribute is set, the select element is rendered as a list box, and the user may select multiple options. yes queen, multi-select energy. 🌈

If the size is not set, the default size (height) is the number of elements. If the size is set to 1, the element is rendered as a pop-up menu.

πŸŽ€ options

A list of options in key => value format. Each key is the unique id of an option tag, and its corresponding value is the text displayed in the element. so the key is the ID, the value is what your user actually sees. iykyk πŸ’œ

πŸŽ€ selected

πŸŽ€ value

A list of keys (unique option ids) which will be pre-set to "selected". Can also be addressed as value for consistency with the other elements. 🫢

"value" is an alias for "selected".

πŸŽ€ constrain_options

πŸŽ€ constrain_values

If true, an In constraint will automatically be added to the widget, using the key names from "options". so she's checking that whatever got submitted is actually one of your options. no randoms allowed. periodt. πŸ’…

"constrain_values" is an alias for "constrain_options".

πŸŽ€ retain_default

If true, overrides the default behaviour, so that after a field is missing from the form submission, the xml output will contain the default value, rather than be empty. so instead of getting ghosted with an empty output, you keep your default. iconic. πŸ’–

πŸŽ€ prepare

πŸŽ€ process

πŸŽ€ containerize

okay so the original page just... lists these three. no descriptions, no notes, nothing. 😭 they're part of the method roster, bestie, and we're keeping them here because we keep everything. don't come for me, i'm just the messenger 🧚


πŸ’« SEE ALSO πŸ’«

  • HTML::Widget::Element

go read her sister pages, they're all part of the same girl group πŸ‘‘


πŸ‘‘ AUTHOR πŸ‘‘

Sebastian Riedel, sri@oook.de


πŸ“œ LICENSE πŸ“œ

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


and that's the whole page, bestie!! this doc came from perl v5.36.0, dated 2023-08-10 β€” so go forth, render your selects, constrain your options, and remember: default size is 1 and we do NOT forget it. mwah πŸ’‹βœ¨πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from