Skip Menu |

This queue is for tickets about the HTML-Widget CPAN distribution.

Report information
The Basics
Id: 19657
Status: resolved
Priority: 0/
Queue: HTML-Widget

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

Bug Information
Severity: Important
Broken in: 1.07
Fixed in: (no value)



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...
This has been fixed in svn, and will be included in v1.09. You should note that as of v1.09, Select and RadioGroup elements will no longer get an In constraint automatically added, as it was considered "too much magic". To get the same behaviour, you'll have to call $e->constrain_values(1) on each relevant element. The svn repository is at http://oook.de/svn/trunk/HTML-Widget/ (The svn url and mailing list address have also been added to the docs!) Thanks, Carl