NAME
Data::HTML::Element::Button - Data object for HTML button element.
SYNOPSIS
use Data::HTML::Element::Button;
my $obj = Data::HTML::Element::Button->new(%params);
my $autofocus = $obj->autofocus;
my $css_class = $obj->css_class;
my $data = $obj->data;
my $data_type = $obj->data_type;
my $disabled = $obj->disabled;
my $form = $obj->form;
my $form_action = $obj->form_action;
my $form_enctype = $obj->form_enctype;
my $form_method = $obj->form_method;
my $form_no_validate = $obj->form_no_validate;
my $id = $obj->id;
my $name = $obj->name;
my $pop_over_target = $obj->pop_over_target;
my $type = $obj->type;
my $value = $obj->value;
METHODS
new
my $obj = Data::HTML::Element::Button->new(%params);
Constructor.
Returns instance of object.
autofocus
Button autofocus flag.
Default value is 0.
css_class
Button CSS class.
Default value is undef.
data
Button data content. It's reference to array. Data type of data is described in 'data_type' parameter.
Default value is [].
data_type
Button data type for content.
Possible value are: plain tags
Default value is 'plain'.
disabled
Button autofocus flag.
Default value is 0.
form
Button form id.
Default value is undef.
form_action
Button form action URL.
Default value is undef.
form_enctype
Button form encoding. It's valuable for 'submit' type.
Possible values are: application/x-www-form-urlencoded multipart/form-data text/plain
Default value is undef.
form_method
Button form method. It's valuable for 'submit' type.
Possible values are: get post
Default value is 'get'.
form_no_validate
Button formnovalidate flag.
Default value is 0.
id
Button identifier.
Default value is undef.
name
Button name.
Default value is undef.
pop_over_target
Button pop over target id.
Default value is undef.
type
Button element type.
Possible types: button reset submit
Default value is 'button'.
value
Button value.
Default value is undef.
autofocus
my $autofocus = $obj->autofocus;
Get button autofocus flag.
Returns bool value (1/0).
css_class
my $css_class = $obj->css_class;
Get CSS class for button.
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.
disabled
my $disabled = $obj->disabled;
Get button disabled flag.
Returns bool value (1/0).
form
my $form = $obj->form;
Get button form id.
Returns string.
form_action
my $form_action = $obj->form_action;
Get button form action URL.
Returns string.
form_enctype
my $form_enctype = $obj->form_enctype;
Get button form enctype.
Returns string.
form_method
my $form_method = $obj->form_method;
Get button form method.
Returns string.
form_no_validate
my $form_no_validate = $obj->form_no_validate;
Get formnovalidate flag.
Returns bool value (1/0).
id
my $id = $obj->id;
Get button identifier.
Returns string.
name
my $name = $obj->name;
Get button name.
Returns string.
pop_over_target
my $pop_over_target = $obj->pop_over_target;
Get button pop over target id.
Returns string.
type
my $type = $obj->type;
Get button type.
Returns string.
value
my $value = $obj->value;
Get button value.
Returns string.
ERRORS
new():
Parameter 'autofocus' must be a bool (0/1).
Value: %s
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 'disabled' must be a bool (0/1).
Value: %s
Parameter 'form_enctype' has bad value.
Value: %s
Parameter 'form_method' has bad value.
Parameter 'formnovalidate' must be a bool (0/1).
Value: %s
Parameter 'type' has bad value.
EXAMPLE1
use strict;
use warnings;
use Data::HTML::Element::Button;
my $obj = Data::HTML::Element::Button->new;
# Print out.
print 'Data type: '.$obj->data_type."\n";
print 'Form method: '.$obj->form_method."\n";
print 'Type: '.$obj->type."\n";
# Output:
# Data type: plain
# Form method: get
# Type: button
EXAMPLE2
use strict;
use warnings;
use Data::HTML::Element::Button;
use Tags::Output::Raw;
my $obj = Data::HTML::Element::Button->new(
# Tags(3pm) structure.
'data' => [
['b', 'span'],
['d', 'Button'],
['e', 'span'],
],
'data_type' => 'tags',
);
my $tags = Tags::Output::Raw->new;
# Serialize data to output.
$tags->put(@{$obj->data});
my $data = $tags->flush(1);
# Print out.
print 'Data (serialized): '.$data."\n";
print 'Data type: '.$obj->data_type."\n";
print 'Form method: '.$obj->form_method."\n";
print 'Type: '.$obj->type."\n";
# Output:
# Data (serialized): <span>Button</span>
# Data type: tags
# Form method: get
# Type: button
EXAMPLE3
use strict;
use warnings;
use Data::HTML::Element::Button;
my $obj = Data::HTML::Element::Button->new(
# Plain content.
'data' => [
'Button',
],
'data_type' => 'plain',
);
# Serialize data to output.
my $data = join ' ', @{$obj->data};
# Print out.
print 'Data: '.$data."\n";
print 'Data type: '.$obj->data_type."\n";
print 'Form method: '.$obj->form_method."\n";
print 'Type: '.$obj->type."\n";
# Output:
# Data: Button
# Data type: plain
# Form method: get
# Type: button
DEPENDENCIES
Data::HTML::Element::Utils, Error::Pure, List::Util, Mo, Mo::utils, 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.11