NAME
Tags::HTML::Element::Form - Tags helper for HTML form element.
SYNOPSIS
use Tags::HTML::Element::Form;
my $obj = Tags::HTML::Element::Form->new(%params);
$obj->cleanup;
$obj->init($form);
$obj->prepare;
$obj->process;
$obj->process_css;
METHODS
new
my $obj = Tags::HTML::Element::Form->new(%params);
Constructor.
background_color
Form background color.
Default value is '#f2f2f2'.
css
'CSS::Struct::Output' object for "process_css" processing.
Default value is undef.
tags
'Tags::Output' object for "process" processing.
Default value is undef.
init
$obj->init($form);
Initialize Tags structure for fields defined in $form
.
Accepted $form
is Data::HTML::Element::Form.
Returns undef.
prepare
$obj->prepare;
Process initialization before page run.
Do nothing in this object.
Returns undef.
process
$obj->process;
Process Tags structure to output.
Returns undef.
process_css
$obj->process_css;
Process CSS::Struct structure for output.
Returns undef.
ERRORS
new():
From Class::Utils::set_params():
Unknown parameter '%s'.
From Tags::HTML::new():
Parameter 'css' must be a 'CSS::Struct::Output::*' class.
Parameter 'tags' must be a 'Tags::Output::*' class.
init():
Form object must be a 'Data::HTML::Element::Form' instance.
process():
From Tags::HTML::process():
Parameter 'tags' isn't defined.
process_css():
From Tags::HTML::process_css():
Parameter 'css' isn't defined.
EXAMPLE
use strict;
use warnings;
use CSS::Struct::Output::Indent;
use Data::HTML::Element::Form;
use Tags::HTML::Element::Form;
use Tags::Output::Indent;
# Object.
my $css = CSS::Struct::Output::Indent->new;
my $tags = Tags::Output::Indent->new;
my %p = (
'css' => $css,
'tags' => $tags,
);
my $obj = Tags::HTML::Element::Form->new(%p);
my $form = Data::HTML::Element::Form->new(
'css_class' => 'form',
'data' => [
['b', 'p'],
['b', 'button'],
['a', 'type', 'submit'],
['d', 'Save'],
['e', 'button'],
['e', 'p'],
],
'data_type' => 'tags',
'label' => 'Form for submit',
);
# Initialize.
$obj->init($form);
# Process form.
$obj->process;
$obj->process_css;
# Print out.
print $tags->flush;
print "\n\n";
print $css->flush;
# Output:
# <form class="form" method="get">
# <fieldset>
# <legend>
# Form for submit
# </legend>
# <p>
# <button type="submit">
# Save
# </button>
# </p>
# </fieldset>
# </form>
#
# .form {
# border-radius: 5px;
# background-color: #f2f2f2;
# padding: 20px;
# }
# .form fieldset {
# padding: 20px;
# border-radius: 15px;
# }
# .form legend {
# padding-left: 10px;
# padding-right: 10px;
# }
DEPENDENCIES
Class::Utils, Error::Pure, Scalar::Util, Tags::HTML, Tags::HTML::Element::Utils.
REPOSITORY
https://github.com/michal-josef-spacek/Tags-HTML-Element
AUTHOR
Michal Josef Špaček mailto:skim@cpan.org
LICENSE AND COPYRIGHT
© 2022-2024 Michal Josef Špaček
BSD 2-Clause License
VERSION
0.15