This is quickly becoming my favorite idiom for creating
CGI::scrolling_list (and other form elements ), but I'm wondering if it can be shortened any further?
Essentially, I need a sorted-by-name display. It's not a *major* concern ATM, but I can see those 2 hashes getting large eventually ...
my $sth = $dbh->prepare( "SELECT id, display_name FROM membership "
+ );
my $rawMembers = $dbh->selectall_arrayref( $sth, { Slice => {} } );
my %memberOpts = map { $_->{id} => $_->{display_name} } @$rawMember
+s;
my %memberLookup = reverse %memberOpts;
my $memberWidget = $q->scrolling_list(
-name => 'memberships',
-values => [ @memberLookup{ sort keys %mem
+berLookup } ],
-labels => \%memberOpts,
-default => [],
-multiple => 1,
-size => 5,
);
After I create these little widgets, they're passed off to HTML_TEMPLATE ... i'm more wondering if anyone sees a way to ditch the second copy of the hash.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.