HTML::...Element(3pm)

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

πŸ’– NAME πŸ’–

HTML::Widget::Element β€” bestie, it's the Element Base Class ✨


🌸 SYNOPSIS 🌸

my $e = $widget->element( $type, $name, {disabled => 'disabled'} );
$e->name('bar');
$e->class('foo');

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so it's literally just the Element Base Class. that's the whole vibe. πŸ’…


πŸ‘‘ METHODS πŸ‘‘

✨ new ✨

no cap, it's just... new. iconic behavior honestly. πŸŽ€

✨ attributes ✨

✨ attrs ✨

Arguments: %attributes

Arguments: \%attributes

Return Value: $element

Arguments: none

Return Value: \%attributes

so it accepts either a list of key/value pairs or a hash-ref. your choice bestie 🫢

$e->attributes( $key => $value );
$e->attributes( { $key => $value } );

it hands back the $element object so you can chain methods like the main character you are πŸ’…βœ¨

As of v1.10, passing a hash-ref no longer deletes current attributes β€” instead the attributes get added to the current attributes hash. slay, but also lowkey a behavior change, so heads up.

which means the attributes hash-ref can no longer be emptied using $e->attributes( { } ); 😭 instead you gotta do:

%{ $e->attributes } = ();

and here's the special case, don't skip it: if no arguments are passed, the return value is a hash-ref of attributes instead of the object reference. this is for backwards compatibility, so this works:

$e->attributes->{key} = $value;

attrs is an alias for attributes. same thing, different font. πŸ’–

✨ container ✨

Arguments: \%attributes

Return Value: $container

creates a new $container_class. defaults to HTML::Widget::Container. ✨

✨ id ✨

Arguments: $widget

Return Value: $id

creates an element id. iconic. πŸŽ€

✨ init ✨

Arguments: $widget

gets called once when process() gets called for the very first time. one time only bestie, like a first impression πŸ¦‹

✨ mk_error ✨

Arguments: $widget, \@errors

Return Value: $error

creates a new HTML::Widget::Error. 😭 (affectionate)

✨ mk_input ✨

Arguments: $widget, \%attributes, \@errors

Return Value: $input_tag

creates a new input tag. periodt. πŸ’…

✨ mk_tag ✨

Arguments: $widget, $tagtype, \%attributes, \@errors

Return Value: $element_tag

creates a new tag. πŸ”₯

✨ mk_label ✨

Arguments: $widget, $name, $comment, \@errors

Return Value: $label_tag

creates a new label tag. πŸŽ€

✨ name ✨

Arguments: $name

Return Value: $name

contains the element name. it's giving "identity". 🌸

✨ passive ✨

Arguments: $bool

Return Value: $bool

defines if the element gets automatically rendered. πŸ‘€

✨ prepare ✨

Arguments: $widget

gets called whenever $widget->process gets called, before $element->process. so like, it preps the vibe check first. ✨

✨ process ✨

Arguments: \%params, \@uploads

Return Value: \@errors

gets called whenever $widget->process is called.

returns an arrayref of HTML::Widget::Error objects. 😭

✨ containerize ✨

Arguments: $widget, $value, \@errors

Return Value: $container_tag

containerizes the element, label and error for later rendering. 🫢 uses HTML::Widget::Container by default, but ngl this can be over-ridden on a class or instance basis via container_class. iykyk.

✨ container_class ✨

Arguments: $class

Return Value: $class

contains the class to use for contain the element which then get rendered. defaults to HTML::Widget::Container. container_class can be set at a class or instance level:

HTML::Widget::Element->container_class('My::Container');
# Override default to custom class

HTML::Widget::Element::Password->container_class(undef);
# Passwords use the default class

$w->element('Textfield')->name('foo')->container_class->('My::Other::Container');
# This element only will use My::Other::Container to render

✨ find_elements ✨

Return Value: \@elements

for non-block-container elements, it simply returns a one-element list containing this element. simple. clean. iconic. ⭐

✨ new ✨

(yeah bestie it's listed again, we don't ask questions, we just keep every single detail πŸ’€)

✨ allow_filter ✨

used by $widget->filter_all. if false, the filter won't be added.

Default true. βœ…

✨ allow_constraint ✨

used by $widget->constraint_all. if false, the filter won't be added.

Default true. βœ…


πŸ’œ AUTHOR πŸ’œ

Sebastian Riedel, sri@oook.de β€” king behavior honestly πŸ‘‘


🌈 LICENSE 🌈

this library is free software, you can redistribute it and/or modify it under the same terms as Perl itself. 🫢


cute lil sign-off: this page is HTML::...Element(3pm) from the User Contributed Perl Documentation, and it's giving perl v5.36.0, dated 2023-08-10. mwah πŸ’‹ no cap, that's the whole thing bestie, go write some widgets πŸŽ€βœ¨πŸ¦‹
πŸ“¦ where this page comes from