| HTML-Shakan documentation | Contained in the HTML-Shakan distribution. |
HTML::Shakan::Field::Choice - choice field
use HTML::Shakan::Field::Choice;
HTML::Shakan::Field::Choice->new(
name => 'pref',
choices => [qw/tokyo osaka kyoto/],
);
# or shortcut
use HTML::Shakan::Fields;
ChoiceField(
name => 'pref',
choices => [qw/tokyo osaka kyoto/],
);
# if you want radio button
ChoiceField(
name => 'pref',
choices => [qw/tokyo osaka kyoto/],
widget => 'radio',
);
Choice field implementation. This field may show in html as <select></select> tag.
HTML::Shakan::Field
| HTML-Shakan documentation | Contained in the HTML-Shakan distribution. |
package HTML::Shakan::Field::Choice; use Any::Moose; extends 'HTML::Shakan::Field'; has '+widget' => ( default => 'select' ); has choices => ( is => 'ro', isa => 'ArrayRef', required => 1, ); has 'id_tmpl' => ( is => 'ro', isa => 'Str', default => 'id_%s_%s', ); override 'get_constraints' => sub { my $self = shift; my ($name, $constraints) = super(); return ( $name => [ @$constraints, ['CHOICE' => $self->choices] ] ); }; no Any::Moose; __PACKAGE__->meta->make_immutable; __END__