From caa5688f6a17a31ad7c44f5c6b09c5f08dfde390 Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Fri, 17 Oct 2008 13:17:10 +0000 Subject: [PATCH] XXX: radio default --- lib/HTML/Form/Simple.pm | 4 ++-- t/html.t | 11 ++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/HTML/Form/Simple.pm b/lib/HTML/Form/Simple.pm index 18be571..440f404 100644 --- a/lib/HTML/Form/Simple.pm +++ b/lib/HTML/Form/Simple.pm @@ -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 { diff --git a/t/html.t b/t/html.t index 166ab11..a3ac799 100644 --- 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) ], + [ + '', + '', + ], + 'radio default' +); + is_deeply( [ $form->radio(foo => ['foo', ''], 'test', {value => '', id => ''}) ], [ -- 2.30.0