[Dbix-class] DBIx::Class::HTMLWidget (checkboxes)
Dave Howorth
dhoworth at mrc-lmb.cam.ac.uk
Fri Jul 14 13:32:47 CEST 2006
A couple of comments:
Ash Berlin wrote:
> Dennis Schön wrote:
>>Ash Berlin wrote:
>>
>>>Dennis Schön wrote:
>>>
>>>>I narrowed the problem down to the following code in HTMLWidget.pm line 43:
>>>>
>>>>my %cb = map {$_->name => undef if
>>>>$_->isa('HTML::Widget::Element::Checkbox')} @{ $result->{_elements} };
I don't think this code works. Try the test program I posted below.
>>>>[the %cb hash ought to contain the checkbox names as keys]
>>>>
>>>>I replaced that line with the not so fancy, but for me working:
>>>>my %cb;
>>>>foreach (@{ $result->{_elements} }) {
>>>> if ( $_->isa('HTML::Widget::Element::Checkbox') ) {
>>>> $cb{$_->name} = undef;
>>>> }
>>>>}
This code works for me
>>>Could you test the latest SVN version?
>>>http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class-HTMLWidget/
This link points to something that claims to be V0.05, while the version
on CPAN claims to be V0.06.
>>>I know there have been a lot of changes to the CB code. Let us know how
>>>the SVN version copes with you checkboxes.
>>>
>>Still no success. :-( I tried to debug a bit but unfortunatly i don't
>>really understand whats going on. Especially the "$result->{_embedded}".
>>
>> 36 # find all checkboxes
>> 37 my @elements;
>> 38 ····
>> 39 if ($result->{_embedded}) {
>> 40 my @widgets = @{ $result->{_embedded} || [] };
>> 41 foreach (@widgets) {
>> 42 push @elements, $_->get_elements();
>> 43 }
>> 44 } else {
>> 45 @elements = $result->elements;
>> 46 }
>> 47
>> 48 my %cb = map {$_->name => undef } grep {
>>$_->isa('HTML::Widget::Element::Checkbox')}·
>> 49 @elements;
>>
>>that is the relevant code in the latest svn version. In my case line 39
>>returns true but "@widgets" is empty -> which results in an empty "%cb".
>>
>>Again, if i replace all this code with my snippet from above everything
>>is working.
>>
>>Dennis
>>
>>
> Could you send me the snippet that produces your Widget?
>
> (Part of the problem here is that no-one ever got round to producing any
> tests for this module. Sloppy, and I've not got round to doing so either
> yet)
>
> Thanks
> Ash
#!/usr/bin/perl
use strict;
use warnings;
my @array = (1, 2, 3, 4, 5);
my %hash;
use Data::Dumper;
%hash = ();
%hash = map {$_ => undef if $_ % 2 == 0} @array;
print join(' ', sort keys %hash), "\n";
print Dumper(\%hash);
%hash = ();
foreach (@array) {
if ( $_ % 2 == 0 ) {
$hash{$_} = undef;
}
}
print "\n", join(' ', sort keys %hash), "\n";
print Dumper(\%hash);
Cheers, Dave
More information about the Dbix-class
mailing list