On Thu Jul 23 18:07:18 2009, RSRCHBOY wrote:
Show quoted text> It would be nice if HTML::FormHandler::Field (and its descendent
> classes) stringified properly, so that things like:
>
> my $user = $form->field('username');
>
> print "My username is: $user\n";
>
> would "just work".
What about
my $user = $form->value('username');
which would be sugar for:
sub value {
my ($form, $fieldname) = @_;
return $form->field($fieldname)->value;
}
It'd probably need to be smarter than that to handle multi valued by
returning an array in array context, an array ref for multiple values
called in scalar context, or a scalar if it's a single value.
The advantage is that you get the shorter sugared syntax, yet it's
explicit that what you're getting is the the value, not the Field object.
It seems that "value" is already a method on the FormHandler object, so
perhaps the name is wrong, but it's just sugar ... val('fieldname') perhaps?