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