fixed file fields
[catagits/Reaction.git] / lib / Reaction / UI / Widget / Field / ChooseOne.pm
CommitLineData
8f19d042 1package Reaction::UI::Widget::Field::ChooseOne;
2
3use Reaction::UI::WidgetClass;
4
5class ChooseOne is 'Reaction::UI::Widget::Field', which {
6
664d660c 7 implements fragment option_is_required {
8 if ($_{viewport}->attribute->required) {
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
341;
35
6ab43711 36__END__;
8f19d042 37
5a1a893e 38=head1 NAME
8f19d042 39
5a1a893e 40Reaction::UI::Widget::Field::ChooseOne
8f19d042 41
5a1a893e 42=head1 DESCRIPTION
8f19d042 43
5a1a893e 44See L<Reaction::UI::Widget::Field>
8f19d042 45
5a1a893e 46=head1 FRAGMENTS
8f19d042 47
5a1a893e 48=head2 field
8f19d042 49
5a1a893e 50Renders a series fragment C<option> for each C<value_choices> in the viewport
8f19d042 51
5a1a893e 52Additional varibles set: C<is_required> - Boolean, self-explanatory
8f19d042 53
5a1a893e 54=head2 option
55
56C<content> is a dummy variable, but th additional variables C<v_value>, C<v_name>
57and C<is_selected> are set
58
59=head1 AUTHORS
60
61See L<Reaction::Class> for authors.
62
63=head1 LICENSE
64
65See L<Reaction::Class> for the license.
8f19d042 66
67=cut