X-Git-Url: http://git.shiar.net/gitweb.cgi/perl/html-form-simple.git/blobdiff_plain/08784cd0bf249108184d0fa6860623e81c4ab5ac..473797e7d8bb0922a1e56294dff2ad9e82202593:/lib/HTML/Form/Simple.pm?ds=sidebyside diff --git a/lib/HTML/Form/Simple.pm b/lib/HTML/Form/Simple.pm index 58e8753..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 { @@ -213,6 +213,8 @@ sub check { } } exists $rows->[$_]->{value} or $rows->[$_]->{value} = $_ + 1 for 0 .. $#$rows; + $rows->[0]->{id} = $attr->{id} || $rows->[0]->{name} || $attr->{name} || $name #XXX: // + if ref $label ne 'ARRAY' and defined $rows->[0] and not defined $rows->[0]->{id}; $self->select($name, $rows, {%$attr, type => 'checkbox'}); } @@ -250,25 +252,69 @@ HTML::Form::Simple - Generate HTML form elements =head1 DESCRIPTION +Set up a form object with new(). The HTML for the opening and closing +C<<