HTML::...Result(3pm)

πŸ“¦
version 1.11 Β· 3 versions
, in debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– 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): $value or \@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 of perl v5.36.0, dated 2023-08-10, straight out of the HTML::...Result(3pm) section of your friendly neighbourhood User Contributed Perl Documentation. mwah πŸ’–πŸŽ€πŸ¦‹
πŸ“¦ where this page comes from