aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Reaction/UI/Widget/Field/Collection.pm
blob: c54f8a68f5777e6f889c541067cde21bfb455473 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
package Reaction::UI::Widget::Field::Collection;

use Reaction::UI::WidgetClass;

use namespace::clean -except => [ qw(meta) ];


before fragment widget {
  arg 'label' => localized $_{viewport}->label;
};

implements fragment list {
  render 'item' => over $_{viewport}->value_names;
};

implements fragment item {
  arg 'name' => localized $_;
};

__PACKAGE__->meta->make_immutable;


1;

__END__;


=head1 NAME

Reaction::UI::Widget::Field::Collection - A field representing a collection

=head1 DESCRIPTION

This field class will render a collection of values found in the viewport's
C<value_names> and localised before passed to the layout.

=head1 FRAGMENTS

=head2 widget

renders C<label> and C<list> passing additional variable "viewport"

=head2 label

C<content> contains the viewport's label

=head2 list

renders fragment item over the viewport's C<value_names>

=head2 item

C<content> contains the value of the current item ($_ / $_{_})

=head1 LAYOUT SETS

=head2 base

  share/skin/base/layout/field/collection.tt

The following layouts are provided:

=over 4

=item widget

Renders the C<label_box> and C<list> fragments.

=item label_box

Renders a C<span> element containing the C<label> argument.

=item list

Renders the C<item>s inside a C<div> and C<ul> element.

=item item

Renders the C<name> argument inside a C<li> element.

=back

=head2 default

  share/skin/default/layout/field/collection.tt

This layout set extends the C<NEXT> one in the parent skin.

The following layouts are provided:

=over 4

=item label_box

The same as in the C<base> skin, except the label is surrounded by
a C<strong> element.

=back

=head1 AUTHORS

See L<Reaction::Class> for authors.

=head1 LICENSE

See L<Reaction::Class> for the license.

=cut