NAME
Data::HTML::Element::Form - Data object for HTML form element.
SYNOPSIS
use Data::HTML::Element::Form;
my $obj = Data::HTML::Element::Form->new(%params);
my $action = $obj->action;
my $css_class = $obj->css_class;
my $data = $obj->data;
my $data_type = $obj->data_type;
my $enctype = $obj->enctype;
my $id = $obj->id;
my $label = $obj->label;
my $method = $obj->method;
METHODS
new
my $obj = Data::HTML::Element::Form->new(%params);
Constructor.
action
Form action.
Default value is undef.
css_class
Form CSS class.
Default value is undef.
data
Data content. It's reference to array.
Data type of data is described in 'data_type' parameter.
Default value is [].
data_type
Data type for content.
Possible value are: plain tags
The 'plain' content are string(s). The 'tags' content is structure described in Tags.
Default value is 'plain'.
enctype
Form enctype, attribute which specifies how the form-data should be encoded when submitting it to the server.
Possible values are:
(undefined - same as application/x-www-form-urlencoded)
application/x-www-form-urlencoded
multipart/form-data
text/plain
Default value is undef.
id
Form identifier.
Default value is undef.
label
Form label.
Default value is undef.
method
Form method.
Default value is 'get'.
Possible methods are: get and post
Returns instance of object.
action
my $action = $obj->action;
Get form action.
Returns string.
css_class
my $css_class = $obj->css_class;
Get CSS class for form.
Returns string.
data
my $data = $obj->data;
Get data inside button element.
Returns reference to array.
data_type
my $data_type = $obj->data_type;
Get button data type.
Returns string.
enctype
my $enctype = $obj->enctype;
Get enctype, attribute which specifies how the form-data should be encoded when submitting it to the server.
Returns string.
id
my $id = $obj->id;
Get form identifier.
Returns string.
label
my $label = $obj->label;
Get form label.
Returns string.
method
my $method = $obj->method;
Get form method.
Returns string.
ERRORS
new():
Parameter 'css_class' has bad CSS class name.
Value: %s
Parameter 'css_class' has bad CSS class name (number on begin).
Value: %s
Parameter 'data' must be a array.
Value: %s
Reference: %s
Parameter 'data' in 'plain' mode must contain reference to array with scalars.
Parameter 'data' in 'tags' mode must contain reference to array with references to array with Tags structure.
Parameter 'data_type' has bad value.
Parameter 'enctype' has bad value.
Value: %s
Parameter 'method' has bad value.
Value: %s
EXAMPLE1
use strict;
use warnings;
use Data::HTML::Element::Form;
my $obj = Data::HTML::Element::Form->new;
# Print out.
print 'Method: '.$obj->method."\n";
# Output:
# Method: get
EXAMPLE2
use strict;
use warnings;
use Data::HTML::Element::Form;
my $obj = Data::HTML::Element::Form->new(
'action' => '/action.pl',
'css_class' => 'form',
'enctype' => 'multipart/form-data',
'id' => 'form-id',
'label' => 'Form label',
'method' => 'post',
);
# Print out.
print 'Action: '.$obj->action."\n";
print 'CSS class: '.$obj->css_class."\n";
print 'Enctype: '.$obj->enctype."\n";
print 'Id: '.$obj->id."\n";
print 'Label: '.$obj->label."\n";
print 'Method: '.$obj->method."\n";
# Output:
# Action: /action.pl
# CSS class: form
# Enctype: multipart/form-data
# Id: form-id
# Label: Form label
# Method: post
DEPENDENCIES
Error::Pure, List::Util, Mo, Mo::utils::CSS, Readonly.
REPOSITORY
https://github.com/michal-josef-spacek/Data-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.10