e95f1f7bdc550efae24a713e2304c99e51491932
[catagits/Reaction.git] / lib / Reaction / UI / Widget / Field / Container.pm
1 package Reaction::UI::Widget::Field::Container;
2
3 use Reaction::UI::WidgetClass;
4
5 use namespace::clean -except => [ qw(meta) ];
6
7 before fragment widget {
8   arg name  => $_{viewport}->name;
9 };
10
11 implements fragment maybe_label {
12   return unless $_{viewport}->has_label;
13   arg label => $_{viewport}->label;
14   render 'label';
15 };
16
17 implements fragment field_list {
18   render field => over $_{viewport}->fields;
19 };
20
21 implements fragment field {
22   render 'viewport';
23 };
24
25 __PACKAGE__->meta->make_immutable;
26
27 1;
28
29 __END__;
30
31 =head1 NAME
32
33 Reaction::UI::Widget::Field::Container - A field containing multiple values
34
35 =head1 DESCRIPTION
36
37 This widget implements a field containing multiple value viewports found in
38 the current viewport's C<fields> attribute.
39
40 =head1 FRAGMENTS
41
42 =head2 widget
43
44 Sets the C<name> argument to the viewport's C<name> attribute.
45
46 =head2 maybe_label
47
48 Sets the C<label> argument to the viewport's C<label> attribute value and
49 renders the C<label> fragment when the viewport has a label defined.
50
51 =head2 field_list
52
53 Sequentially renders the C<fields> of the viewport;
54
55 =head2 field
56
57 Renders the C<field> viewport passed by C<field_list>
58
59 =head1 LAYOUT SETS
60
61 =head2 base
62
63   share/skin/base/layout/field/container.tt
64
65 The following layouts are provided:
66
67 =over 4
68
69 =item widget
70
71 Renders a C<fieldset> element containing the C<maybe_label> and C<field_list>
72 fragments.
73
74 =item label
75
76 Renders a C<legend> element for the C<fieldset> containing the C<label> argument.
77
78 =item field
79
80 Wraps the next C<field> fragment in a C<span> element.
81
82 =back
83
84 =head1 AUTHORS
85
86 See L<Reaction::Class> for authors.
87
88 =head1 LICENSE
89
90 See L<Reaction::Class> for the license.
91
92 =cut
93