Commit | Line | Data |
2f670e13 |
1 | package Reaction::UI::Widget::Field::Mutable::ChooseOne; |
8f19d042 |
2 | |
3 | use Reaction::UI::WidgetClass; |
4 | |
bae75bee |
5 | use namespace::clean -except => [ qw(meta) ]; |
6 | extends 'Reaction::UI::Widget::Field::Mutable'; |
8f19d042 |
7 | |
bae75bee |
8 | |
9 | |
10 | implements fragment option_is_required { |
11 | if ($_{viewport}->value_is_required) { |
12 | render 'option_is_required_yes'; |
13 | } else { |
14 | render 'option_is_required_no'; |
15 | } |
16 | }; |
17 | |
18 | implements fragment option_list { |
19 | render option => over $_{viewport}->value_choices; |
20 | }; |
21 | |
22 | implements fragment option { |
23 | arg option_name => $_->{name}; |
24 | arg option_value => $_->{value}; |
25 | }; |
26 | |
27 | implements fragment option_is_selected { |
28 | if ($_{viewport}->is_current_value($_->{value})) { |
29 | render 'option_is_selected_yes'; |
30 | } else { |
31 | render 'option_is_selected_no'; |
32 | } |
8f19d042 |
33 | }; |
34 | |
bae75bee |
35 | __PACKAGE__->meta->make_immutable; |
36 | |
37 | |
8f19d042 |
38 | 1; |
39 | |
6ab43711 |
40 | __END__; |
8f19d042 |
41 | |
5a1a893e |
42 | =head1 NAME |
8f19d042 |
43 | |
e516f7e6 |
44 | Reaction::UI::Widget::Field::Mutable::ChooseOne - Choose one from a list of available values |
8f19d042 |
45 | |
5a1a893e |
46 | =head1 DESCRIPTION |
8f19d042 |
47 | |
f9b32c83 |
48 | See L<Reaction::UI::Widget::Field::Mutable>. This widget provides the user with a |
49 | field where he can select a single value from a list of many. |
8f19d042 |
50 | |
5a1a893e |
51 | =head1 FRAGMENTS |
8f19d042 |
52 | |
5a1a893e |
53 | =head2 field |
8f19d042 |
54 | |
5a1a893e |
55 | Renders a series fragment C<option> for each C<value_choices> in the viewport |
8f19d042 |
56 | |
5a1a893e |
57 | Additional varibles set: C<is_required> - Boolean, self-explanatory |
8f19d042 |
58 | |
5a1a893e |
59 | =head2 option |
60 | |
61 | C<content> is a dummy variable, but th additional variables C<v_value>, C<v_name> |
62 | and C<is_selected> are set |
63 | |
f9b32c83 |
64 | =head2 option_is_required |
65 | |
66 | Renders either C<option_is_required_yes> or C<option_is_required_no> depending on |
67 | the viewport's C<value_is_required> attribute. |
68 | |
69 | =head2 option_list |
70 | |
71 | Renders the C<option> fragment over the viewport's C<value_choices>. This populates |
72 | the list of available values. |
73 | |
74 | =head2 option_is_selected |
75 | |
76 | Renders either C<option_is_selected_yes> or C<option_is_selected_no> depending on |
77 | if the viewport's C<is_current_value> method returns true on the current topic |
78 | arguments C<value> key. |
79 | |
80 | =head1 LAYOUT SETS |
81 | |
82 | =head2 base |
83 | |
84 | share/skin/base/layout/field/mutable/choose_one.tt |
85 | |
86 | This layout set renders a C<select> element with the available values as C<option>s. |
87 | |
5a1a893e |
88 | =head1 AUTHORS |
89 | |
90 | See L<Reaction::Class> for authors. |
91 | |
92 | =head1 LICENSE |
93 | |
94 | See L<Reaction::Class> for the license. |
8f19d042 |
95 | |
96 | =cut |