Hello all,

Hopefully this list is the correct place for this patch,
I almost sent it to the HTML::Widget list.

Attached is a patch to allow DBIx::Class::HTMLWidget to
handle widgets with radio elements.  Previously, the
fill_widget method would overwrite the value of each
radio element with the value from the database.

Also included is a correction to the populate_from_widget
method's handling of checkbox elements.

Best,
Brian Kirkbride
--- lib/DBIx/Class/HTMLWidget.pm        2006-06-15 10:04:35.000000000 -0500
+++ lib/DBIx/Class/HTMLWidget.pm        2006-06-27 23:13:22.646127965 -0500
@@ -25,6 +25,8 @@
         next unless $name && $dbic->can($name) && $element->can('value');
         if($element->isa('HTML::Widget::Element::Checkbox')) {
                          $element->checked($dbic->$name?1:0);
+                 } elsif ($element->isa('HTML::Widget::Element::Radio')) {
+                         $element->checked($dbic->$name eq $element->value ? 1 
: 0);
                  } else {
                          $element->value($dbic->$name)
                                unless 
$element->isa('HTML::Widget::Element::Password');
@@ -39,7 +41,7 @@
                unless ref $result && $result->isa('HTML::Widget::Result');
 
        #   find all checkboxes
-    my %cb = map {$_->name => undef if 
$_->isa('HTML::Widget::Element::Checkbox')} 
+    my %cb = map {$_->name => undef } grep { 
$_->isa('HTML::Widget::Element::Checkbox') } 
     @{ $result->{_elements} };
 
     foreach my $col ( $dbic->result_source->columns ) {
_______________________________________________
List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
Wiki: http://dbix-class.shadowcatsystems.co.uk/
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
Searchable Archive: http://www.mail-archive.com/[email protected]/

Reply via email to