added localization to core widgets
[catagits/Reaction.git] / lib / Reaction / UI / Widget / Field.pm
1 package Reaction::UI::Widget::Field;
2
3 use Reaction::UI::WidgetClass;
4
5 use namespace::clean -except => [ qw(meta) ];
6
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) {
18     arg label => localized $label;
19     render 'label';
20   }
21 };
22
23 __PACKAGE__->meta->make_immutable;
24
25
26 1;
27
28 __END__;
29
30 =head1 NAME
31
32 Reaction::UI::Widget::Field
33
34 =head1 DESCRIPTION
35
36 =head1 FRAGMENTS
37
38 =head2 widget
39
40 Additional variables available in topic hash: "viewport", "id", "name".
41
42 Renders "label","field" and "message"
43
44 =head2 field
45
46  C<content> will contain the value, if any,  of the field.
47
48 =head2 label
49
50  C<content> will contain the label, if any, of the field.
51
52 =head2 message
53
54  C<content> will contain the message, if any, of the field.
55
56 =head1 AUTHORS
57
58 See L<Reaction::Class> for authors.
59
60 =head1 LICENSE
61
62 See L<Reaction::Class> for the license.
63
64 =cut