simplify value widgets to reduce PROCESS calls, make some classes immutable which...
[catagits/Reaction.git] / lib / Reaction / UI / Widget / Field.pm
CommitLineData
8f19d042 1package Reaction::UI::Widget::Field;
2
3use Reaction::UI::WidgetClass;
4
5class 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 widget renders [qw/label field message/
14 => { id => func('self', 'id'),
15 name => func('self', 'name'),
16 viewport => func('self', 'viewport'), }
17 ];
18
a5200252 19 field renders [ string { $_{viewport}->value }, ];
20
8f19d042 21 label renders [ string { $_{viewport}->label }, ];
22 message renders [ string { $_{viewport}->message }, ];
23
8f19d042 24};
25
261;
27
6ab43711 28__END__;
29
5a1a893e 30=head1 NAME
31
32Reaction::UI::Widget::Field
33
34=head1 DESCRIPTION
35
36=head1 ATTRIBUTES
37
38=head2 id
39
40Str, lazy builds.
41
42=head2 name
43
44Str, lazy builds.
45
46=head1 METHODS
47
48=head2 build_id
49
50Returns the viewport's C<event_id_for('value')>
51
52=head2 build_name
53
54Returns the viewport's C<event_id_for('value')>
55
56=head1 FRAGMENTS
57
58=head2 widget
59
60Additional variables available in topic hash: "viewport", "id", "name".
61
62Renders "label","field" and "message"
63
64=head2 field
65
66 C<content> will contain the value, if any, of the field.
67
68=head2 label
69
70 C<content> will contain the label, if any, of the field.
71
72=head2 message
73
74 C<content> will contain the message, if any, of the field.
75
76=head1 AUTHORS
77
78See L<Reaction::Class> for authors.
79
80=head1 LICENSE
81
82See L<Reaction::Class> for the license.
83
84=cut