---
name: "HTML::FormFu::Element"
section: "3pm"
platform: "linux"
package: "libhtml-formfu-perl"
version: "2.07000-2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/HTML::FormFu::Element"
---

# HTML::FormFu::Element(3pm)

Element Base Class

## NAME

HTML::FormFu::Element - Element Base Class

## VERSION

version 2.07

## SYNOPSIS

```
    ---
    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
```

## DESCRIPTION

Elements are the basic building block of all forms. Elements may be logical form-fields, blocks such as `"div"`s and `"fieldset"`s, non-blocks such as `"hr"`s and other special elements such as tables.

For simple, automatic handling of fieldsets see the "auto\_fieldset" in HTML::FormFu setting.

See "deflators" in HTML::FormFu for details of Deflators.

See "FORM LOGIC AND VALIDATION" in HTML::FormFu for details of Filters, Constraints, Inflators, Validators and Transformers.

## METHODS

### name

For field element, this value is used as the `"name"` attribute which the field's value is associated with.

For all elements, the "name" value can be useful for identifying and retrieving specific elements.

### is\_field

Return Value: boolean

Returns `"true"` or `"false"` depending on whether the element is a logical form-field.

This is used by "get\_fields" in HTML::FormFu.

## BUILDING AN ELEMENT

### load\_config\_file

Arguments: `$filename`

Arguments: \\@filenames

Populate an element using a config file:

```
    ---
    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 you shouldn't include the file extension in the passed string. This allows you to change your config-file type, without having to change the code that loads the files.

### config\_file\_path

Arguments: `$directory_name`

"config\_file\_path" defines where configuration files will be searched for, if an absolute path is not 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 up to the form, searching for a defined value.

### 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 originally used to create the element.

## 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".

### 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.

### 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.

### get\_parent

Arguments: \\%options

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

Traverses the parent hierarchy, returning the first parent that matches the supplied options.

### 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

- 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

- 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

The following are base classes for other elements, and generally needn't be used directly.

- 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.

## 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\>

## COPYRIGHT AND LICENSE

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.
