r59846@cain (orig r397): matthewt | 2007-11-09 14:04:24 +0000
[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   has id   => (isa => 'Str', is => 'ro', lazy_build => 1);
8   has name => (isa => 'Str', is => 'ro', lazy_build => 1);
9
10   implements _build_id   => as { shift->viewport->event_id_for('value'); };
11   implements _build_name => as { shift->viewport->event_id_for('value'); };
12
13   fragment widget [qw/label field message/
14                   => { id       => func('self', 'id'),
15                        name     => func('self', 'name'), }
16                  ];
17
18   fragment field   [ string { $_{viewport}->value },   ];
19
20   fragment label   [ string { $_{viewport}->label   }, ];
21   fragment message [ string { $_{viewport}->message }, ];
22
23 };
24
25 1;
26
27 __END__;
28
29 =head1 NAME
30
31 Reaction::UI::Widget::Field
32
33 =head1 DESCRIPTION
34
35 =head1 ATTRIBUTES
36
37 =head2 id
38
39 Str, lazy builds.
40
41 =head2 name
42
43 Str, lazy builds.
44
45 =head1 METHODS
46
47 =head2 _build_id
48
49 Returns the viewport's C<event_id_for('value')>
50
51 =head2 _build_name
52
53 Returns the viewport's C<event_id_for('value')>
54
55 =head1 FRAGMENTS
56
57 =head2 widget
58
59 Additional variables available in topic hash: "viewport", "id", "name".
60
61 Renders "label","field" and "message"
62
63 =head2 field
64
65  C<content> will contain the value, if any,  of the field.
66
67 =head2 label
68
69  C<content> will contain the label, if any, of the field.
70
71 =head2 message
72
73  C<content> will contain the message, if any, of the field.
74
75 =head1 AUTHORS
76
77 See L<Reaction::Class> for authors.
78
79 =head1 LICENSE
80
81 See L<Reaction::Class> for the license.
82
83 =cut