Reaction::UI::Widget::Field::Mutable - Mutable fields


Reaction documentation Contained in the Reaction distribution.

Index


Code Index:

NAME

Top

Reaction::UI::Widget::Field::Mutable - Mutable fields

DESCRIPTION

Top

An extension of Reaction::UI::Widget::Field representing fields whose values can be mutated.

FRAGMENTS

Top

widget

The following additional arguments are provided:

field_id

Contains the viewport's event id for value_string.

field_name

Defaults to the field_id argument unless already defined

field_type

Defaults to text.

field_class

A string containing the joined class attribute. Defaults to action-field and the current viewport's name.

exists_event

Contains the event id for exists.

exists_value

Defaults to 1.

message_fragment

Renders nothing if the viewport doesn't have a message.

Otherwise, the message argument will be set to the localised string contained in the viewport's message attribute and the message fragment will be rendered.

field_is_required

Will render either field_is_required_yes or field_is_required_no depending on if value_is_required on the viewport returns true and the viewports value_string is empty.

LAYOUT SETS

Top

base

  share/skin/base/layout/field/mutable.tt

The following layouts are provided:

widget

Builds a span element with a class attribute set to the field_class argument. The element contents will be the label_fragment, field and message_fragment fragments.

label

Builds a label element with the for attribute set to the value of field_id and the other attributes used from the field_is_required argument. The content will be the label argument.

field_is_required_yes

Sets the class attribute to required_field.

field_is_required_no

Empty.

message

Renders a span element with the message as content.

field

Renders the input field. The field_body fragment is used to set the value.

field_body

Creates the value attribute for the input element.

default

  share/skin/default/layout/field/mutable.tt

The following layouts are provided:

message

Will render the original message fragment followed by a br element.

SUBCLASSES

Top

Reaction::UI::Widget::Field::Mutable::Boolean

A widget allowing the manipulation of boolean values.

Reaction::UI::Widget::Field::Mutable::ChooseMany

Allows the user to choose many items from a list of available values.

Reaction::UI::Widget::Field::Mutable::ChooseOne

Allows the user to choose a single item from a list of available values.

Reaction::UI::Widget::Field::Mutable::DateTime

A simple DateTime Reaction::UI::Widget::Field::Mutable subclass.

Reaction::UI::Widget::Field::Mutable::File

A simple file input field.

Reaction::UI::Widget::Field::Mutable::HiddenArray

Renders an array reference value as a series of hidden fields.

Reaction::UI::Widget::Field::Mutable::Integer

A simple integer Reaction::UI::Widget::Field::Mutable.

Reaction::UI::Widget::Field::Mutable::MatchingPasswords

Password input requiring that the password be entered twice, e.g. to input a new password.

Reaction::UI::Widget::Field::Mutable::Password

A password input Reaction::UI::Widget::Field::Mutable.

Reaction::UI::Widget::Field::Mutable::Number

A simple number Reaction::UI::Widget::Field::Mutable input field.

Reaction::UI::Widget::Field::Mutable::String

A simple string Reaction::UI::Widget::Field::Mutable input field.

Reaction::UI::Widget::Field::Mutable::Text

A multiline input Reaction::UI::Widget::Field::Mutable.

SEE ALSO

Top

* Reaction::UI::Widget::Field

AUTHORS

Top

See Reaction::Class for authors.

LICENSE

Top

See Reaction::Class for the license.


Reaction documentation Contained in the Reaction distribution.

package Reaction::UI::Widget::Field::Mutable;

use Reaction::UI::WidgetClass;

use namespace::clean -except => [ qw(meta) ];
extends 'Reaction::UI::Widget::Field';



 before fragment widget {
   arg 'field_id' => event_id 'value_string';
   arg 'field_name' => event_id 'value_string' unless defined $_{field_name};
   arg 'field_type' => 'text';
   arg 'field_class' => "action-field " . $_{viewport}->name;

   # these two are to fire force_events in viewports
   # where you can end up without an event for e.g.
   # HTML checkbox fields

   arg 'exists_event' => event_id 'exists';
   arg 'exists_value' => 1;
 };

 implements fragment message_fragment {
   my $vp = $_{viewport};
   return unless $vp->has_message;
   my $message = $vp->message;
   if ($message) {
     arg message => localized $message;
     render 'message';
   }
 };

 implements fragment field_is_required {
   my $vp = $_{viewport};
   if ( $vp->value_is_required && !$vp->value_string ) {
       render 'field_is_required_yes';
   } else {
       render 'field_is_required_no';
   }
 };

__PACKAGE__->meta->make_immutable;


1;

__END__;