Subject: | Select widget creates invalid constraint for options where the value is '0'. |
HTML::Widget::Element::Select uses this bit of code to determine the
unique values for the options so it can create an 'In' constraint for them:
my %options = @{ $self->options };
my %seen;
my @uniq = grep { $seen{$_}++ == 0 ? $_ : 0 } keys %options;
I'm not sure if there is more to the grep than meets the eye, but it
doesn't work if you use it with a widget like this:
$w->element( 'Select', 'yesno' )->options(qw( 1 Yes 0 No ));
because the grep eliminates the 0, so @uniq contains only ('1').
I made it work in my install with just this change:
--- Select.pm.orig 2006-06-01 21:38:41.000000000 -0400
+++ Select.pm 2006-06-01 21:35:23.000000000 -0400
@@ -86,8 +86,7 @@
}
my %options = @{ $self->options };
- my %seen;
- my @uniq = grep { $seen{$_}++ == 0 ? $_ : 0 } keys %options;
+ my @uniq = keys %options;
$w->constraint( 'In', $name )->in( @uniq )
if @uniq;
Hopefully you guys don't mind the rt.cpan.org route, I didn't see in the
docs where you wanted bugs sent, let me know if you want me to report
future ones somewhere else (or if it's fixed already, let me know if you
have a public svn/cvs repository I could have checked first, I couldn't
find that either...)
Thanks for the great module, it's saved me tons of time and repitition...