port actionform, field widgets to declarative system
[catagits/Reaction.git] / lib / Reaction / UI / Widget / Field.pm
1 package Reaction::UI::Widget::Field;
2
3 use Reaction::UI::WidgetClass;
4
5 class Field, which {
6
7   before fragment widget {
8     arg 'field_id' => event_id 'value';
9     arg 'field_name' => event_id 'value';
10     arg 'field_type' => 'text';
11     if ($_{viewport}->can('value_string')) {
12       arg 'field_value' => $_{viewport}->value_string;
13     }
14   };
15
16   implements fragment message_fragment {
17     if (my $message = $_{viewport}->message) {
18       arg message => $message;
19       render 'message';
20     }
21   };
22
23   implements fragment label_fragment {
24     if (my $label = $_{viewport}->label) {
25       arg label => $label;
26       render 'label';
27     }
28   };
29
30 };
31
32 1;
33
34 __END__;
35
36 =head1 NAME
37
38 Reaction::UI::Widget::Field
39
40 =head1 DESCRIPTION
41
42 =head1 ATTRIBUTES
43
44 =head2 id
45
46 Str, lazy builds.
47
48 =head2 name
49
50 Str, lazy builds.
51
52 =head1 METHODS
53
54 =head2 _build_id
55
56 Returns the viewport's C<event_id_for('value')>
57
58 =head2 _build_name
59
60 Returns the viewport's C<event_id_for('value')>
61
62 =head1 FRAGMENTS
63
64 =head2 widget
65
66 Additional variables available in topic hash: "viewport", "id", "name".
67
68 Renders "label","field" and "message"
69
70 =head2 field
71
72  C<content> will contain the value, if any,  of the field.
73
74 =head2 label
75
76  C<content> will contain the label, if any, of the field.
77
78 =head2 message
79
80  C<content> will contain the message, if any, of the field.
81
82 =head1 AUTHORS
83
84 See L<Reaction::Class> for authors.
85
86 =head1 LICENSE
87
88 See L<Reaction::Class> for the license.
89
90 =cut