XXX: radio default
authorMischa POSLAWSKY <perl@shiar.org>
Fri, 17 Oct 2008 13:17:10 +0000 (13:17 +0000)
committerMischa POSLAWSKY <perl@shiar.org>
Sun, 19 Oct 2008 14:03:21 +0000 (14:03 +0000)
lib/HTML/Form/Simple.pm
t/html.t

index 18be571a0f04b3bbe6cbff2e873779256454b55a..440f4042f607104e815ec86dd0e7678e5b8bcaf5 100644 (file)
@@ -171,7 +171,7 @@ sub select {
 
 sub radio {
        my $self = shift;
-       my ($name, $rows, $label, $attr) = $self->_attr(3, @_);
+       my ($name, $rows, $label, $default, $attr) = $self->_attr(4, @_);
 
        if (not defined $rows) {
                if (defined $label) {
@@ -194,7 +194,7 @@ sub radio {
                }
        }
 
-       $self->select($name, $rows, {%$attr, type => 'radio'});
+       $self->select($name, $rows, $default, {%$attr, type => 'radio'});
 }
 
 sub check {
index 166ab111149cfd8bc160ad17571b7284084b4e4e..a3ac7996e530800210755a21afff19af0f89fe7e 100644 (file)
--- a/t/html.t
+++ b/t/html.t
@@ -5,7 +5,7 @@ use warnings;
 
 use Test::More;
 
-plan tests => 68;
+plan tests => 72;
 
 use_ok('HTML::Form::Simple');
 
@@ -346,6 +346,15 @@ is_deeply(
        'multiple radio labels'
 );
 
+is_deeply(
+       [ $form->radio(undef, [0, 1], undef, 0) ],
+       [
+               '<input checked type="radio" value="0">',
+               '<input type="radio" value="1">',
+       ],
+       'radio default'
+);
+
 is_deeply(
        [ $form->radio(foo => ['foo', ''], 'test', {value => '', id => ''}) ],
        [