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