1 package Reaction::UI::Widget::Field::Mutable;
3 use Reaction::UI::WidgetClass;
5 use namespace::clean -except => [ qw(meta) ];
6 extends 'Reaction::UI::Widget::Field';
10 before fragment widget {
11 arg 'field_id' => event_id 'value_string';
12 arg 'field_name' => event_id 'value_string' unless defined $_{field_name};
13 arg 'field_type' => 'text';
14 arg 'field_class' => "action-field " . $_{viewport}->name;
16 # these two are to fire force_events in viewports
17 # where you can end up without an event for e.g.
18 # HTML checkbox fields
20 arg 'exists_event' => event_id 'exists';
21 arg 'exists_value' => 1;
24 implements fragment message_fragment {
25 my $vp = $_{viewport};
26 return unless $vp->has_message;
27 my $message = $vp->message;
29 arg message => localized $message;
34 implements fragment field_is_required {
35 my $vp = $_{viewport};
36 if ( $vp->value_is_required && !$vp->value_string ) {
37 render 'field_is_required_yes';
39 render 'field_is_required_no';
43 __PACKAGE__->meta->make_immutable;
52 Reaction::UI::Widget::Field::Mutable - Mutable fields
56 An extension of L<Reaction::UI::Widget::Field> representing fields
57 whose values can be mutated.
63 The following additional arguments are provided:
69 Contains the viewport's event id for C<value_string>.
73 Defaults to the C<field_id> argument unless already defined
81 A string containing the joined class attribute. Defaults to
82 C<action-field> and the current viewport's C<name>.
86 Contains the event id for C<exists>.
94 =head2 message_fragment
96 Renders nothing if the viewport doesn't have a message.
98 Otherwise, the C<message> argument will be set to the localised string contained
99 in the viewport's C<message> attribute and the C<message> fragment will be rendered.
101 =head2 field_is_required
103 Will render either C<field_is_required_yes> or C<field_is_required_no> depending on
104 if C<value_is_required> on the viewport returns true and the viewports C<value_string>
111 share/skin/base/layout/field/mutable.tt
113 The following layouts are provided:
119 Builds a C<span> element with a class attribute set to the C<field_class> argument.
120 The element contents will be the C<label_fragment>, C<field> and C<message_fragment>
125 Builds a C<label> element with the C<for> attribute set to the value of C<field_id> and
126 the other attributes used from the C<field_is_required> argument. The content will be
127 the C<label> argument.
129 =item field_is_required_yes
131 Sets the class attribute to C<required_field>.
133 =item field_is_required_no
139 Renders a C<span> element with the C<message> as content.
143 Renders the input field. The C<field_body> fragment is used to set the value.
147 Creates the C<value> attribute for the input element.
153 share/skin/default/layout/field/mutable.tt
155 The following layouts are provided:
161 Will render the original C<message> fragment followed by a C<br> element.
169 =item L<Reaction::UI::Widget::Field::Mutable::Boolean>
171 A widget allowing the manipulation of boolean values.
173 =item L<Reaction::UI::Widget::Field::Mutable::ChooseMany>
175 Allows the user to choose many items from a list of available values.
177 =item L<Reaction::UI::Widget::Field::Mutable::ChooseOne>
179 Allows the user to choose a single item from a list of available values.
181 =item L<Reaction::UI::Widget::Field::Mutable::DateTime>
183 A simple DateTime L<Reaction::UI::Widget::Field::Mutable> subclass.
185 =item L<Reaction::UI::Widget::Field::Mutable::File>
187 A simple file input field.
189 =item L<Reaction::UI::Widget::Field::Mutable::HiddenArray>
191 Renders an array reference value as a series of hidden fields.
193 =item L<Reaction::UI::Widget::Field::Mutable::Integer>
195 A simple integer L<Reaction::UI::Widget::Field::Mutable>.
197 =item L<Reaction::UI::Widget::Field::Mutable::MatchingPasswords>
199 Password input requiring that the password be entered twice, e.g. to input a new
202 =item L<Reaction::UI::Widget::Field::Mutable::Password>
204 A password input L<Reaction::UI::Widget::Field::Mutable>.
206 =item L<Reaction::UI::Widget::Field::Mutable::Number>
208 A simple number L<Reaction::UI::Widget::Field::Mutable> input field.
210 =item L<Reaction::UI::Widget::Field::Mutable::String>
212 A simple string L<Reaction::UI::Widget::Field::Mutable> input field.
214 =item L<Reaction::UI::Widget::Field::Mutable::Text>
216 A multiline input L<Reaction::UI::Widget::Field::Mutable>.
224 =item * L<Reaction::UI::Widget::Field>
230 See L<Reaction::Class> for authors.
234 See L<Reaction::Class> for the license.