NAME
Data::HTML::Element::Option - Data object for HTML option element.
SYNOPSIS
use Data::HTML::Element::Option;
my $obj = Data::HTML::Element::Option->new(%params);
my $css_class = $obj->css_class;
my $data = $obj->data;
my $data_type = $obj->data_type;
my $disabled = $obj->disabled;
my $id = $obj->id;
my $label = $obj->label;
my $selected = $obj->selected;
my $value = $obj->value;
METHODS
new
my $obj = Data::HTML::Element::Option->new(%params);
Constructor.
css_class
Option 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: cb plain tags
The 'cb' content is code reference. The 'plain' content are string(s). The 'tags' content is structure described in Tags.
Default value is 'plain'.
disabled
Disabled flag.
Default value is 0.
id
Option identifier.
Default value is undef.
label
Option label.
Default value is undef.
selected
Selected flag.
Default value is 0.
value
Option value.
Default value is undef.
Returns instance of object.
css_class
my $css_class = $obj->css_class;
Get CSS class for option.
Returns string.
data
my $data = $obj->data;
Get data inside option element.
Returns reference to array.
data_type
my $data_type = $obj->data_type;
Get option data type.
Returns string.
disabled
my $disabled = $obj->disabled;
Get option disabled flag.
Returns bool value (1/0).
id
my $id = $obj->id;
Get option identifier.
Returns string.
label
my $label = $obj->label;
Get option label.
Returns string.
selected
my $selected = $obj->selected;
Get selected flag.
Returns bool value (1/0).
value
my $value = $obj->value;
Get option value.
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 'disabled' must be a bool (0/1).
Value: %s
Parameter 'selected' must be a bool (0/1).
Value: %s
EXAMPLE
use strict;
use warnings;
use Data::HTML::Element::Option;
my $obj = Data::HTML::Element::Option->new(
'css_class' => 'opt',
'id' => 7,
'label' => 'Audi',
'selected' => 1,
'value' => 'audi',
);
# Print out.
print 'Id: '.$obj->id."\n";
print 'CSS class: '.$obj->css_class."\n";
print 'Label: '.$obj->label."\n";
print 'Value: '.$obj->value."\n";
print 'Selected: '.$obj->selected."\n";
# Output:
# Id: 7
# CSS class: opt
# Label: Audi
# Value: audi
# Selected: 1
DEPENDENCIES
Data::HTML::Element::Utils, Error::Pure, List::Util, Mo, Mo::utils, Mo::utils::CSS.
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.17