HTML::...:Select(3pm)
π 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
- debian trixie: libhtml-widget-perl 1.11-7 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libhtml-widget-perl 1.11-7 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libhtml-widget-perl 1.11-7 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libhtml-widget-perl 1.11-7 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms