X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FReaction%2FUI%2FWidget%2FField%2FMutable.pm;h=9fc565e2ede6c44983037a63b3f4a38b644c7bbd;hb=56d5a4eb0f9cef44c02759663616dd1f0893d483;hp=1364b399f1ae647acff9b34946f0b63d17624e2f;hpb=39453d9dc1fd054200132592c24a2dd9fa1683c6;p=catagits%2FReaction.git diff --git a/lib/Reaction/UI/Widget/Field/Mutable.pm b/lib/Reaction/UI/Widget/Field/Mutable.pm index 1364b39..9fc565e 100644 --- a/lib/Reaction/UI/Widget/Field/Mutable.pm +++ b/lib/Reaction/UI/Widget/Field/Mutable.pm @@ -23,9 +23,8 @@ extends 'Reaction::UI::Widget::Field'; implements fragment message_fragment { my $vp = $_{viewport}; - my $message = $_{viewport}->message; - $message ||= $vp->name.' is required' - if $vp->value_is_required && !$vp->value_string; + return unless $vp->has_message; + my $message = $vp->message; if ($message) { arg message => localized $message; render 'message'; @@ -47,3 +46,191 @@ __PACKAGE__->meta->make_immutable; 1; __END__; + +=head1 NAME + +Reaction::UI::Widget::Field::Mutable - Mutable fields + +=head1 DESCRIPTION + +An extension of L representing fields +whose values can be mutated. + +=head1 FRAGMENTS + +=head2 widget + +The following additional arguments are provided: + +=over 4 + +=item field_id + +Contains the viewport's event id for C. + +=item field_name + +Defaults to the C argument unless already defined + +=item field_type + +Defaults to C. + +=item field_class + +A string containing the joined class attribute. Defaults to +C and the current viewport's C. + +=item exists_event + +Contains the event id for C. + +=item exists_value + +Defaults to C<1>. + +=back + +=head2 message_fragment + +Renders nothing if the viewport doesn't have a message. + +Otherwise, the C argument will be set to the localised string contained +in the viewport's C attribute and the C fragment will be rendered. + +=head2 field_is_required + +Will render either C or C depending on +if C on the viewport returns true and the viewports C +is empty. + +=head1 LAYOUT SETS + +=head2 base + + share/skin/base/layout/field/mutable.tt + +The following layouts are provided: + +=over 4 + +=item widget + +Builds a C element with a class attribute set to the C argument. +The element contents will be the C, C and C +fragments. + +=item label + +Builds a C