Form::Factory::Control - high-level API for working with form controls
version 0.022
package MyApp::Control::Slider; use Moose; with qw( Form::Feature::Control Form::Feature::Control::Role::ScalarValue ); has minimum_value => ( is => 'rw', isa => 'Num', required => 1, default => 0, ); has maximum_value => ( is => 'rw', isa => 'Num', required => 1, default => 100, ); has value => ( is => 'rw', isa => 'Num', required => 1, default => 50, ); sub current_value { my $self = shift if (@_) { $self->value(shift) } return $self->value; } package Form::Factory::Control::Custom::Slider; sub register_implementation { 'MyApp::Control::Slider' }
Allows for high level processing, validation, filtering, etc. of form control information.
This is the action to which the control is attached. This is a weak reference to prevent memory leaks.
This is the base name for the control.
This holds a copy the documentation attribute of the original meta attribute.
This is the list of Form::Factory::Feature::Role::Control features associated with the control.
This is the value of the control. This attribute provides a has_value predicate. See "current_value".
has_value
This is the default or fallback value for the control used when "value" is not set. This attribute provides a has_default_value predicate. See "current_value".
has_default_value
This may be a method name or a code reference that can be run in order to coerce the control's current value to the action attribute's value during action processing. The given method or subroutine will always be called with 3 arguments:
The action object the control has been attached to.
The control object we are converting from.
The current value of the control.
The method or subroutien should return the converted value.
This attribute provides a has_control_to_value predicate.
has_control_to_value
This is either a method name (to be called on the action the control is connected with) to a code reference. This method or subroutine will be called to conver the action attribute value to the control's value.
The method or subroutine will always be called with three arguments:
The action object the control belongs to.
The control object that will receive the value.
The value of the attribute that is being assigned to the control.
The method or subroutine should return the converted value.
This attribute provides a has_value_to_control predicate.
has_value_to_control
This is the current value of the control. If "value" is set, then that is returned. If that is not set, but "defautl_value" is set, then that is returned. If neither are set, then undef is returned.
undef
This may also be passed a value. In which case the "value" is set and that value is returned.
Returns true if either value or default_value is set.
value
default_value
Given an attribute value, convert it to a control value. This will cause any associated Form::Factory::Feature::Role::ControlValueConverter features to run and run the "value_to_control" conversion. The value to convert should be passed as the lone argument. The converted value is returned.
Given a control value, convert it to an attribute value. This will run any Form::Factory::Feature::Role::ControlValueConverter features and the "control_to_value" conversion (if set). The value to convert should be passed as the only argument and the converted value is returned.
$control->set_attribute_value($action, $attribute);
Sets the value of the action attribute with current value of teh control.
my $feature = $control->get_feature_by_name($name);
Given a feature name, it returns the named feature object. Returns undef if no such feature is attached to this control.
if ($control->has_feature($name)) { # do something about it... }
Returns a true value if the named feature is attached to this control. Returns false otherwise.
Andrew Sterling Hanenkamp <hanenkamp@cpan.org>
This software is copyright (c) 2015 by Qubling Software LLC.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Form::Factory, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Form::Factory
CPAN shell
perl -MCPAN -e shell install Form::Factory
For more information on module installation, please visit the detailed CPAN module installation guide.