Skip Menu |

This queue is for tickets about the Form-Sensible CPAN distribution.

Report information
The Basics
Id: 64544
Status: resolved
Priority: 0/
Queue: Form-Sensible

People
Owner: Nobody in particular
Requestors: LGODDARD [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 0.20002
Fixed in: (no value)



Subject: Select value
Not sure if this is me or the POD: CODE: use strict; use warnings; use Test::More; BEGIN { use_ok('Form::Sensible'); } use Form::Sensible::Field::Select; my $select_field = Form::Sensible::Field::Select->new( name => 'bread_type', accepts_multiple => 1 ); $select_field->add_option('wheat', 'Wheat Bread'); $select_field->add_option('white', 'White Bread'); $select_field->add_option('sour', 'Sourdough Bread'); $select_field->value('wheat'); isa_ok( $select_field->value, 'ARRAY' ); done_testing(); OUTPUTS: ok 1 - use Form::Sensible; not ok 2 - The class isa ARRAY # Failed test 'The class isa ARRAY' # at t/bug.pl line 24. # The class isn't a 'ARRAY' it's a '' 1..2
This is a doc bug and has been corrected with the current release. When a field is set to 'accepts_multiple' = false, (the default) the value, including selects, will be a single scalar. When a field is set to 'accepts_multiple' = true, the value will be an array ref. It will be an array ref even if only a single option has been selected. Jay On Thu Jan 06 11:21:13 2011, LGODDARD wrote: Show quoted text
> Not sure if this is me or the POD: > > CODE: > > use strict; > use warnings; > > use Test::More; > > BEGIN { > use_ok('Form::Sensible'); > } > > use Form::Sensible::Field::Select; > > my $select_field = Form::Sensible::Field::Select->new( > name => 'bread_type', > accepts_multiple => 1 > ); > > $select_field->add_option('wheat', 'Wheat Bread'); > $select_field->add_option('white', 'White Bread'); > $select_field->add_option('sour', 'Sourdough Bread'); > > $select_field->value('wheat'); > > isa_ok( $select_field->value, 'ARRAY' ); > > done_testing(); > > OUTPUTS: > > ok 1 - use Form::Sensible; > not ok 2 - The class isa ARRAY > # Failed test 'The class isa ARRAY' > # at t/bug.pl line 24. > # The class isn't a 'ARRAY' it's a '' > 1..2 >