Commit | Line | Data |
---|---|---|
2f670e13 | 1 | package Reaction::UI::Widget::Field::Mutable::ChooseOne; |
8f19d042 | 2 | |
3 | use Reaction::UI::WidgetClass; | |
4 | ||
2f670e13 | 5 | class ChooseOne is 'Reaction::UI::Widget::Field::Mutable', which { |
8f19d042 | 6 | |
664d660c | 7 | implements fragment option_is_required { |
8d80af16 | 8 | if ($_{viewport}->attribute->is_required) { |
664d660c | 9 | render 'options_is_required_yes'; |
10 | } else { | |
11 | render 'options_is_required_no'; | |
12 | } | |
13 | }; | |
14 | ||
15 | implements fragment option_list { | |
16 | render option => over $_{viewport}->value_choices; | |
17 | }; | |
18 | ||
19 | implements fragment option { | |
20 | arg option_name => $_->{name}; | |
21 | arg option_value => $_->{value}; | |
22 | }; | |
23 | ||
24 | implements fragment option_is_selected { | |
25 | if ($_{viewport}->is_current_value($_->{value})) { | |
26 | render 'option_is_selected_yes'; | |
27 | } else { | |
28 | render 'option_is_selected_no'; | |
29 | } | |
30 | }; | |
8f19d042 | 31 | |
32 | }; | |
33 | ||
34 | 1; | |
35 | ||
6ab43711 | 36 | __END__; |
8f19d042 | 37 | |
5a1a893e | 38 | =head1 NAME |
8f19d042 | 39 | |
5a1a893e | 40 | Reaction::UI::Widget::Field::ChooseOne |
8f19d042 | 41 | |
5a1a893e | 42 | =head1 DESCRIPTION |
8f19d042 | 43 | |
5a1a893e | 44 | See L<Reaction::UI::Widget::Field> |
8f19d042 | 45 | |
5a1a893e | 46 | =head1 FRAGMENTS |
8f19d042 | 47 | |
5a1a893e | 48 | =head2 field |
8f19d042 | 49 | |
5a1a893e | 50 | Renders a series fragment C<option> for each C<value_choices> in the viewport |
8f19d042 | 51 | |
5a1a893e | 52 | Additional varibles set: C<is_required> - Boolean, self-explanatory |
8f19d042 | 53 | |
5a1a893e | 54 | =head2 option |
55 | ||
56 | C<content> is a dummy variable, but th additional variables C<v_value>, C<v_name> | |
57 | and C<is_selected> are set | |
58 | ||
59 | =head1 AUTHORS | |
60 | ||
61 | See L<Reaction::Class> for authors. | |
62 | ||
63 | =head1 LICENSE | |
64 | ||
65 | See L<Reaction::Class> for the license. | |
8f19d042 | 66 | |
67 | =cut |