Form::Factory::Control::Role::Value - controls with values
version 0.013
This flags a control as having a value. This may belong in Form::Factory::Control directly, but for now it is here.
This is the value set on the control. It is generally the value that "current_value" gets or sets.
$control->set_attribute_value($action, $attribute);
Sets the value of the action attribute with current value of teh control.
my $value = $control->current_value; $control->current_value($new_value);
The current_value method is an accessor and mutator for values on the control. This is different from the "value" attribute as other attributes or values may be involved in determining what the current value is. For example, a text control defines the current_value something like this:
current_value
text
sub current_value { my $self = shift; if (@_) { $self->value(@_); } return $self->has_value ? $self->value : $self->has_default_value ? $self->default_value : '' ; }
The value will change if set, but the default_value attribute is used if available and it will fall back to an empty string failing that.
default_value
All value controls must also define a has_current_value method. This is used to determine if the control has a current value. This should be a little more robust than a simple check on whether the current_value is defined, though. Rather, it should check if this is a useful value.
has_current_value
Typically, in forms, an empty string submitted indicates a blank value rather than a useful value. That is, it may be defined, but it's not valuable.
This method is only given the control object as it's parameter and the return value is a boolean indicating whether the current value is useful.
Andrew Sterling Hanenkamp <hanenkamp@cpan.org>
<hanenkamp@cpan.org>
Copyright 2009 Qubling Software LLC.
This library is free software. You can redistribute it and/or modify it under the same terms as Perl 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.