HTML-FormBuilder
view release on metacpan or search on metacpan
lib/HTML/FormBuilder/Select.pm view on Meta::CPAN
package HTML::FormBuilder::Select;
use strict;
use warnings;
use Carp;
use Moo;
use namespace::clean;
our $VERSION = '0.13'; ## VERSION
=head1 NAME
HTML::FormBuilder::Select - Select Element Handling for BOM Forms
=cut
=head1 Synopsis
my $select = HTML::FormBuilder::Select->new(
id => 'my-select',
name => 'my_select',
options => [{value => 'foo', text => 'Foo'}, {value => 'bar', text => 'Bar'}],
values => qw(foo),
};
$select->values('bar'); # set only 'bar'
$select->values('foo', 'bar'); # set only 'foo'
my $html = $select->widget_html;
my $hidden_input_html = $select->hidden_html;
=head1 PROPERTIES
=head2 id - id property of form element
=cut
has id => (
is => 'ro',
isa => \&is_str,
lazy => 1,
builder => '_build_id'
);
sub _build_id {
my $self = shift;
return $self->name;
}
=head2 name - name property of form element
=cut
has name => (
is => 'ro',
isa => \&is_str,
required => '1'
);
=head2 options - option arrayref to generate options
=cut
has options => (
is => 'rw',
isa => sub {
die "$_[0] is not ArrayRef[HashRef[Any]]"
unless (ref($_[0]) eq 'ARRAY' && ref($_[0][0]) eq 'HASH');
},
);
=head2 values - values (by value) selected
=cut
( run in 1.485 second using v1.01-cache-2.11-cpan-39bf76dae61 )