SYNOPSIS
see HTML::WidgetDESCRIPTION
Result Class.METHODS
action
Arguments: $actionReturn Value: $action
Contains the form action.
as_xml
Return Value: $xmlReturns xml.
container
Arguments: $tagReturn Value: $tag
Contains the container tag.
enctype
Arguments: $enctypeReturn Value: $enctype
Contains the form encoding type.
errors
error
Arguments: $name, $typeReturn Value: @errors
Returns a list of HTML::Widget::Error objects.
my @errors = $form->errors; my @errors = $form->errors('foo'); my @errors = $form->errors( 'foo', 'ASCII' );
``error'' is an alias for ``errors''.
elements
element
Arguments: $name (optional)Return Value: @elements
If $name argument is supplied, returns a HTML::Widget::Container object for the first element matching $name. Otherwise, returns a list of HTML::Widget::Container objects for all elements.
my @form = $f->elements; my $age = $f->elements('age');
``element'' is an alias for ``elements''.
elements_ref
Arguments: $name (optional)Return Value: \@elements
Accepts the same arguments as ``elements'', but returns an arrayref of results instead of a list.
find_result_element
Arguments: $nameReturn Value: @elements
Looks for the named element and returns a HTML::Widget::Container object for it if found.
elements_for
Arguments: $nameReturn Value: @elements
If the named element is a Block or NullContainer element, return a list of HTML::Widget::Container objects for the contents of that element.
find_elements
Return Value: @elementsExactly the same as ``find_elements'' in HTML::Widget
empty_errors
Arguments: $boolReturn Value: $bool
Create spans for errors even when there's no errors.. (For AJAX validation validation)
has_errors
has_error
have_errors
Arguments: $nameReturn Value: $bool
Returns a list of element names.
my @names = $form->has_errors; my $error = $form->has_errors($name);
``has_error'' and ``have_errors'' are aliases for ``has_errors''.
id
Arguments: $idReturn Value: $id
Contains the widget id.
legend
Arguments: $legendReturn Value: $legend
Contains the legend.
method
Arguments: $methodReturn Value: $method
Contains the form method.
param
Arguments: $nameReturn Value (scalar context): $value or \@values
Return Value (list context): @values
Returns valid parameters with a CGI.pm-compatible param method. (read-only)
params
parameters
Return Value: \%paramsReturns validated params as hashref.
``parameters'' is an alias for ``params''.
subcontainer
Arguments: $tagReturn Value: $tag
Contains the subcontainer tag.
strict
Arguments: $boolReturn Value: $bool
Only consider parameters that pass at least one constraint valid.
submitted
is_submitted
Return Value: $boolReturns true if "$widget->process" received a $query object.
``is_submitted'' is an alias for ``submitted''.
valid
Return Value: @namesArguments: $name
Return Value: $bool
Returns a list of element names. Returns true/false if a name is given.
my @names = $form->valid; my $valid = $form->valid($name);
add_valid
Arguments: $key, $valueReturn Value: $value
Adds another valid value to the hash.
add_error
Arguments: \%attributesReturn Value: $error
$result->add_error({ name => 'foo' });
This allows you to add custom error messages after the widget has processed the input params.
Accepts 'name', 'type' and 'message' arguments. The 'name' argument is required. The default value for 'type' is 'Custom'. The default value for 'message' is 'Invalid Input'.
An example of use.
if ( ! $result->has_errors ) { my $user = $result->valid('username'); my $pass = $result->valid('password'); if ( ! $app->login( $user, $pass ) ) { $result->add_error({ name => 'password', message => 'Incorrect Password', }); } }
In this example, the $result initially contains no errors. If the login() is unsuccessful though, add_error() is used to add an error to the password Element. If the user is shown the form again using "$result->as_xml", they will be shown an appropriate error message alongside the password field.
AUTHOR
Sebastian Riedel, "[email protected]"LICENSE
This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself.