HTML::...Element(3pm)

πŸ“¦
version 2.07000 Β· 5 versions
, in debian bookworm, ubuntu jammy, ubuntu noble

πŸ‘‘ HTML::...Element β€” Element Base Class πŸ’…

okay bestie, welcome to the manual page for HTML::...Element (the 3pm one, you know the vibe) β€” this is the whole Element Base Class situation, and honestly? it's the blueprint for everything. let's go ✨


🌸 VERSION 🌸

version 2.07 β€” that's the one, no cap.


✨ SYNOPSIS ✨

okay so here's the whole thing in action, look at it:

---
elements:
  - type: Text
    name: username
    constraints:
      - type: Required

  - type: Password
    name: password
    constraints:
      - type: Required
      - type: Equal
        others: repeat-password

  - type: Password
    name: repeat-password

  - type: Submit

iconic. obsessed. moving on 🫢


πŸ’– DESCRIPTION πŸ’–

Elements are, like, the basic building block of all forms. periodt. an Element can be a logical form-field, or a block like divs and fieldsets, or a non-block like hrs, or other special elements like tables. it's giving very versatile πŸ‘‘

for simple, automatic handling of fieldsets, go look at the auto_fieldset setting in HTML::FormFu.

for all the tea on Deflators, check deflators in HTML::FormFu.

for Filters, Constraints, Inflators, Validators and Transformers β€” the whole validation cinematic universe β€” see FORM LOGIC AND VALIDATION in HTML::FormFu.


πŸ› οΈ METHODS πŸ› οΈ

name

for a field element, this value gets used as the name attribute that the field's value is associated with.

for all elements, the name value is also useful for identifying and retrieving specific elements. lowkey a great way to keep track of your faves.

is_field

Return Value: boolean

returns true or false depending on whether the element is a logical form-field. vibe check for "are you actually a field or not" πŸ’…

this is used by get_fields in HTML::FormFu.


🧱 BUILDING AN ELEMENT 🧱

load_config_file

Arguments: $filename

Arguments: \@filenames

populates an element using a config file, like so:

---
elements:
  - type: Block
    load_config_file: 'elements.yml'

see load_config_file in HTML::FormFu for further details.

load_config_filestem

Arguments: $filestem

Arguments: \@filestems

like load_config_file, but bestie β€” you should not include the file extension in the passed string. the whole point is that you can change your config-file type without having to change the code that loads the files. so convenient πŸŽ€

config_file_path

Arguments: $directory_name

config_file_path defines where configuration files will be searched for, if an absolute path isn't given to load_config_file.

Default Value: not defined

this method is a special 'inherited accessor', which means it can be set on the form, a block element, or a single element. when the value is read, if no value is defined it automatically traverses the element's hierarchy of parents β€” through any block elements and all the way up to the form β€” searching for a defined value. it's giving main character energy, climbing the whole family tree 🌳

config_callback

see config_callback in HTML::FormFu for details.

populate

see populate in HTML::FormFu for details.

stash

see stash in HTML::FormFu for details.

type

returns the type argument that was originally used to create the element. the origin story, fr fr.


πŸ¦‹ CHANGING DEFAULT BEHAVIOUR πŸ¦‹

render_processed_value

see render_processed_value in HTML::FormFu for details.

force_errors

see force_errors in HTML::FormFu for details.


πŸŽ€ ELEMENT ATTRIBUTES πŸŽ€

see specific element types for which tag attributes are added to.

attributes / attrs

Arguments: [%attributes]

Arguments: [\%attributes]

Return Value: $form

see attributes in HTML::FormFu for details.

attrs is an alias for attributes. same girl, different name πŸ’…

attributes_xml / attrs_xml

see attributes_xml in HTML::FormFu for details.

attrs_xml is an alias for attributes_xml.

add_attributes / add_attrs

Arguments: [%attributes]

Arguments: [\%attributes]

Return Value: $form

see add_attributes in HTML::FormFu for details.

add_attrs is an alias for add_attributes.

add_attributes_xml / add_attrs_xml

see add_attributes_xml in HTML::FormFu for details.

add_attrs_xml is an alias for add_attributes_xml.

del_attributes / del_attrs

Arguments: [%attributes]

Arguments: [\%attributes]

Return Value: $form

see del_attributes in HTML::FormFu for details.

del_attrs is an alias for del_attributes.

del_attributes_xml / del_attrs_xml

see del_attributes_xml in HTML::FormFu for details.

del_attrs_xml is an alias for del_attributes_xml.

the following methods are shortcuts for accessing attributes keys. cute little express lane 🌈

id

Arguments: [$id]

Return Value: $id

get or set the element's DOM id.

Default Value: none


πŸ—„οΈ MODEL / DATABASE INTERACTION πŸ—„οΈ

see HTML::FormFu::Model for further details and available models.

model_config

Arguments: \%config


🎨 RENDERING 🎨

filename

this value identifies which template file should be used by render to render the element.

prepare_id

Arguments: $render

see prepare_id in HTML::FormFu::Role::Element::Field for details.

prepare_attrs

Arguments: $render

see prepare_attrs in HTML::FormFu::Role::Element::Field for details.

render

Return Value: $string


πŸ” INTROSPECTION πŸ”

parent

returns the block element or form object that this element is attached to. your element's parental figure, basically πŸ™ˆ

get_parent

Arguments: \%options

my $repeatable = $field->get_parent({ type => 'Repeatable' });

traverses the parent hierarchy, returning the first parent that matches the supplied options. it goes looking for its people 🧚

form

returns the HTML::FormFu object that the constraint's field is attached to.

clone

see clone in HTML::FormFu for details.


πŸ”₯ ADVANCED CUSTOMISATION πŸ”₯

tt_args

see tt_args in HTML::FormFu for details.

render_method

see render_method in HTML::FormFu for details.


πŸ‘‘ CORE FORM FIELDS πŸ‘‘

the whole squad, alphabetically slaying:

  • HTML::FormFu::Element::Button
  • HTML::FormFu::Element::Checkbox
  • HTML::FormFu::Element::Checkboxgroup
  • HTML::FormFu::Element::ComboBox
  • HTML::FormFu::Element::ContentButton
  • HTML::FormFu::Element::Date
  • HTML::FormFu::Element::Email
  • HTML::FormFu::Element::File
  • HTML::FormFu::Element::Hidden
  • HTML::FormFu::Element::Image
  • HTML::FormFu::Element::Number
  • HTML::FormFu::Element::Password
  • HTML::FormFu::Element::Radio
  • HTML::FormFu::Element::Radiogroup
  • HTML::FormFu::Element::Reset
  • HTML::FormFu::Element::Select
  • HTML::FormFu::Element::Submit
  • HTML::FormFu::Element::Textarea
  • HTML::FormFu::Element::Text
  • HTML::FormFu::Element::URL

🌈 OTHER CORE ELEMENTS 🌈

the rest of the cast, also iconic:

  • HTML::FormFu::Element::Blank
  • HTML::FormFu::Element::Block
  • HTML::FormFu::Element::Fieldset
  • HTML::FormFu::Element::Hr
  • HTML::FormFu::Element::Label
  • HTML::FormFu::Element::Multi
  • HTML::FormFu::Element::Repeatable
  • HTML::FormFu::Element::SimpleTable
  • HTML::FormFu::Element::Src

🧬 ELEMENT BASE CLASSES 🧬

these following ones are base classes for other elements, and generally needn't be used directly. they're the backstage crew, the supporting characters β€” absolutely essential, absolutely not the ones you call up first:

  • HTML::FormFu::Role::Element::Field
  • HTML::FormFu::Role::Element::Group
  • HTML::FormFu::Role::Element::Input
  • HTML::FormFu::Element::_MultiElement
  • HTML::FormFu::Element::_MultiSelect
  • HTML::FormFu::Element::_MultiText
  • HTML::FormFu::Role::Element::NonBlock

πŸ’€ REMOVED METHODS πŸ’€

db

has been removed; use default_args instead.

bestie. it's gone. it's not coming back. use default_args, fr fr 😭

🫢 AUTHOR 🫢

Carl Franks, cfranks@cpan.org


πŸ“œ LICENSE πŸ“œ

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


✍️ AUTHOR ✍️

Carl Franks <cpan@fireartist.com>


this software is copyright (c) 2018 by Carl Franks.

this is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.


okay so that's the whole page β€” and the tiny print at the bottom said perl v5.28.1, dated 2019-01-12. that's a wrap, bestie, you ate this πŸ’…βœ¨πŸŽ€

πŸ“¦ where this page comes from