search spec components factored out of T365
[catagits/Reaction.git] / lib / Reaction / UI / Widget / Field.pm
CommitLineData
8f19d042 1package Reaction::UI::Widget::Field;
2
3use Reaction::UI::WidgetClass;
4
bae75bee 5use namespace::clean -except => [ qw(meta) ];
8f19d042 6
bae75bee 7
8before fragment widget {
9 if ($_{viewport}->can('value_string')) {
10 arg 'field_value' => $_{viewport}->value_string;
11 } else {
12 arg 'field_value' => ''; #$_{viewport}->value;
13 }
14};
15
16implements fragment label_fragment {
17 if (my $label = $_{viewport}->label) {
d219104c 18 arg label => localized $label;
bae75bee 19 render 'label';
20 }
8f19d042 21};
22
bae75bee 23__PACKAGE__->meta->make_immutable;
24
8f19d042 251;
26
6ab43711 27__END__;
28
5a1a893e 29=head1 NAME
30
f9b32c83 31Reaction::UI::Widget::Field - A simple labelled text field
5a1a893e 32
33=head1 DESCRIPTION
34
f9b32c83 35This widget renders a simple labelled text field.
36
5a1a893e 37=head1 FRAGMENTS
38
39=head2 widget
40
f9b32c83 41Sets the C<field_value> argument either to the result of the C<value_string>
42method on the viewport, or to an empty string if the viewport does not support
43the method.
44
45=head2 label_fragment
46
47Will set the C<label> argument to the localised value of the viewport's C<label>
48method and render the C<label> fragment I<if> the viewport's C<label> value
49is true.
50
51=head1 LAYOUT SETS
52
53=head2 base
54
55 share/skin/base/layout/field.tt
56
57The following layouts are provided:
58
59=over 4
60
61=item widget
62
63Renders the C<label_fragment> and C<value_layout> fragments.
64
65=item label
66
67Renders a C<span> element with a C<field_label> class attribute containing the
68C<label> argument and a double colon.
69
70=item value_layout
71
72Renders a C<span> element with a C<field_value> class attribute containing the
73C<field_value> argument.
74
75=back
76
77=head2 default
78
79 share/skin/default/layout/field.tt
80
81This layout set inherits from the C<NEXT> one in the skin inheritance.
82
83The following layouts are provided:
84
85=item label
86
87The same as in the C<base> skin except that the C<label> argument is surrounded
88by a C<strong> element.
89
90=head1 SUBCLASSES
91
92For mutable fields see L<Reaction::UI::Widget::Field::Mutable>.
93
94=over 4
95
96=item L<Reaction::UI::Field::Text>
97
98A simple text subclass of L<Reaction::UI::Field>.
99
100=item L<Reaction::UI::Field::String>
101
102A simple string subclass of L<Reaction::UI::Field>.
103
104=item L<Reaction::UI::Field::RelatedObject>
105
106A simple subclass of L<Reaction::UI::Field>.
107
108=item L<Reaction::UI::Field::Number>
109
110A simple number subclass of L<Reaction::UI::Field>.
111
112=item L<Reaction::UI::Field::Integer>
113
114A simple integer subclass of L<Reaction::UI::Field>.
115
116=item L<Reaction::UI::Field::Image>
117
118A field representing an optional image.
119
120=item L<Reaction::UI::Field::DateTime>
121
122A simple DateTime subclass of L<Reaction::UI::Field>.
123
124=item L<Reaction::UI::Field::Container>
125
126A container field for multiple values.
5a1a893e 127
f9b32c83 128=item L<Reaction::UI::Field::Collection>
5a1a893e 129
f9b32c83 130A field containing a collection of localised values.
5a1a893e 131
f9b32c83 132=item L<Reaction::UI::Field::Boolean>
5a1a893e 133
f9b32c83 134A simple boolean subclass of L<Reaction::UI::Field>.
5a1a893e 135
f9b32c83 136=item L<Reaction::UI::Field::Array>
5a1a893e 137
f9b32c83 138A field representing an array of values, like L<Reaction::UI::Field::Collection>.
5a1a893e 139
f9b32c83 140=back
5a1a893e 141
142=head1 AUTHORS
143
144See L<Reaction::Class> for authors.
145
146=head1 LICENSE
147
148See L<Reaction::Class> for the license.
149
150=cut