HTML::...Result(3pm)
π HTML::...Result π
okay bestie, sit down, hydrate, and let me tell you about HTML::...Result β the Result Class from the HTML::Widget universe. yes, the whole thing is literally about what comes back after your widget does its little processing thing. it's giving β¨resultsβ¨. no cap.
πΈ NAME πΈ
HTML::Widget::Result β the Result Class, and yes she's that girl π
π¦ SYNOPSIS π¦
bestie, this one's lowkey shy β she just points you at her friend:
see HTML::Widget
that's it. that's the whole vibe check. go look at HTML::Widget, iykyk π
π DESCRIPTION π
Result Class. That's the whole description, and honestly? iconic minimalism. she said "I am the result, figure out the rest" π«Ά
β¨ METHODS β¨
here's the main character roster, in order, no skips, no cuts, every single one π
π action
- Arguments:
$action - Return Value:
$action
Contains the form action. the where-to-send-it energy. periodt.
π as_xml
- Return Value:
$xml
Returns xml. that's it, that's the sentence π
π container
- Arguments:
$tag - Return Value:
$tag
Contains the container tag. yes, same name in, same name out, she's consistent π
π enctype
- Arguments:
$enctype - Return Value:
$enctype
Contains the form encoding type. the how do we encode this of it all β¨
π errors, error
- Arguments:
$name,$type - Return Value:
@errors
Returns a list of HTML::Widget::Error objects. all the little oopsies, gathered up for you π₯Ί
my @errors = $form->errors;
my @errors = $form->errors('foo');
my @errors = $form->errors( 'foo', 'ASCII' );
"error" is an alias for "errors". twin sisters fr fr π―
π 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. so like β ask for one, get one; ask for nothing, get the whole squad π
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. same tea, different cup ββ¨
π find_result_element
- Arguments:
$name - Return Value:
@elements
Looks for the named element and returns a HTML::Widget::Container object for it if found. she's hunting. she's on the case. π
π elements_for
- Arguments:
$name - Return 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. opening the box and showing you what's inside π
π find_elements
- Return Value:
@elements
Exactly the same as "find_elements" in HTML::Widget. literally the same, no notes, go read that one π
π empty_errors
- Arguments:
$bool - Return Value:
$bool
Create spans for errors even when there's no errors.. (For AJAX validation validation) β yes she said validation validation, she's excited, let her live ππ
π has_errors, has_error, have_errors
- Arguments:
$name - Return 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". three names, one queen π
π id
- Arguments:
$id - Return Value:
$id
Contains the widget id. her little name tag π·οΈβ¨
π legend
- Arguments:
$legend - Return Value:
$legend
Contains the legend. lore. backstory. π
π method
- Arguments:
$method - Return Value:
$method
Contains the form method. GET? POST? she holds the answer π
π param
- Arguments:
$name - Return Value (scalar context):
$valueor\@values - Return Value (list context):
@values
Returns valid parameters with a CGI.pm-compatible param method. (read-only) β so look, don't touch, bestie π
π params, parameters
- Return Value:
\%params
Returns validated params as hashref. one tidy little bundle π
"parameters" is an alias for "params". β¨
π subcontainer
- Arguments:
$tag - Return Value:
$tag
Contains the subcontainer tag. container's little sibling, still iconic πΈ
π strict
- Arguments:
$bool - Return Value:
$bool
Only consider parameters that pass at least one constraint valid. she has standards π π₯
π submitted, is_submitted
- Return Value:
$bool
Returns true if "$widget->process" received a $query object. did something actually happen? she'll tell you π¦
"is_submitted" is an alias for "submitted". π
π valid
- Return Value:
@names - Arguments:
$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,$value - Return Value:
$value
Adds another valid value to the hash. adding to the collection, slay ββ¨
π add_error
- Arguments:
\%attributes - Return 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. and that's the whole story bestie, it just works ππ
π AUTHOR π
Sebastian Riedel, "sri@oook.de" β the actual legend who made all of this happen π«Άβ¨
π LICENSE π
This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself. so go wild (respectfully) π
and that's a wrap, bestie π this lil page came to you courtesy ofperl v5.36.0, dated2023-08-10, straight out of theHTML::...Result(3pm)section of your friendly neighbourhood User Contributed Perl Documentation. mwah πππ¦
π¦ where this page comes from
- debian trixie: libhtml-widget-perl 1.11-7 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libhtml-widget-perl 1.11-7 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libhtml-widget-perl 1.11-7 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libhtml-widget-perl 1.11-7 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms