| 1 | package HTML::FormHandler::Widget::Field::Role::SelectedOption; | ||
| 2 | # ABSTRACT: allow setting options from options keys | ||
| 3 | $HTML::FormHandler::Widget::Field::Role::SelectedOption::VERSION = '0.410000'; | ||
| 4 | use Moose::Role; | ||
| 5 | use namespace::autoclean; | ||
| 6 | |||
| 7 | sub check_selected_option { | ||
| 8 | my ( $self, $option, $fif ) = @_; | ||
| 9 | my $selected_key = defined($option->{'selected'}) ? | ||
| 10 | $option->{'selected'} | ||
| 11 | : $option->{'checked'}; | ||
| 12 | if ( defined $selected_key ) { | ||
| 13 | return $selected_key; | ||
| 14 | } elsif ( defined $fif ) { | ||
| 15 | return $fif eq $option->{'value'}; | ||
| 16 | } else { | ||
| 17 | return; | ||
| 18 | } | ||
| 19 | } | ||
| 20 | |||
| 21 | 1; | ||
| 22 | |||
| 23 | __END__ | ||
| 24 | |||
| 25 | =pod | ||
| 26 | |||
| 27 | =encoding UTF-8 | ||
| 28 | |||
| 29 | =head1 NAME | ||
| 30 | |||
| 31 | HTML::FormHandler::Widget::Field::Role::SelectedOption - allow setting options from options keys | ||
| 32 | |||
| 33 | =head1 VERSION | ||
| 34 | |||
| 35 | version 0.410000 | ||
| 36 | |||
| 37 | =head1 AUTHOR | ||
| 38 | |||
| 39 | FormHandler Contributors - see HTML::FormHandler | ||
| 40 | |||
| 41 | =head1 COPYRIGHT AND LICENSE | ||
| 42 | |||
| 43 | This software is copyright (c) 2017 by Gerda Shank. | ||
| 44 | |||
| 45 | This is free software; you can redistribute it and/or modify it under | ||
| 46 | the same terms as the Perl 5 programming language system itself. | ||
| 47 | |||
| 48 | =cut |