4b1705829184843d5380428bb824d3dcb7add292
[catagits/Reaction.git] / lib / Reaction / UI / Widget / Field / Mutable / Boolean.pm
1 package Reaction::UI::Widget::Field::Mutable::Boolean;
2
3 use Reaction::UI::WidgetClass;
4
5 use namespace::clean -except => [ qw(meta) ];
6 extends 'Reaction::UI::Widget::Field::Mutable';
7
8
9
10 after fragment widget {
11    arg 'field_type' => 'checkbox';
12 };
13
14 implements fragment is_checked {
15   if ($_{viewport}->value_string) {
16     render 'is_checked_yes';
17   } else {
18     render 'is_checked_no';
19   }
20 };
21
22 __PACKAGE__->meta->make_immutable;
23
24
25 1;
26
27 __END__;
28
29 =head1 NAME
30
31 Reaction::UI::Widget::Field::Boolean - A mutable boolean field
32
33 =head1 DESCRIPTION
34
35 Provides a widget to manipulate a boolean value. This is a subclass of
36 L<Reaction::UI::Widget::Field::Mutable>.
37
38 =head1 FRAGMENTS
39
40 =head2 widget
41
42 Will set the argument C<field_type> to C<checkbox>.
43
44 =head2 is_checked
45
46 Will render the C<is_checked_yes> fragment if the viewport has a true C<value_string>
47 or C<is_checked_no> if it does not.
48
49 =head1 LAYOUT SETS
50
51 =head2 base
52
53   share/skin/base/layout/field/mutable/boolean.tt
54
55 This layout set extends the next C<field/mutable> layout set in the skin inheritance.
56
57 The following layouts are provided:
58
59 =over 4
60
61 =item widget
62
63 Renders the input element that will be the checkbox.
64
65 =item field_body
66
67 Sets the value element attribute to 1 and renders the C<is_checked> fragment afterwards.
68
69 =item is_checked_yes
70
71 Sets the C<checked> attribute of the input element to C<checked>.
72
73 =item is_checked_no
74
75 Empty.
76
77 =back
78
79 =head1 AUTHORS
80
81 See L<Reaction::Class> for authors.
82
83 =head1 LICENSE
84
85 See L<Reaction::Class> for the license.
86
87 =cut