do not alter option hash ref in check()
[perl/html-form-simple.git] / lib / HTML / Form / Simple.pm
index 18be571a0f04b3bbe6cbff2e873779256454b55a..152efe90dc534b8d22ce81fe9eb32e403e142add 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 {
@@ -202,7 +202,7 @@ sub check {
        my ($name, $label, $checked, $attr) = $self->_attr(3, @_);
 
        my $rows = defined $label ? ref $label eq 'ARRAY' ? [@$label] : [$label] : [{}];
-       ref $_ eq 'HASH' or $_ = {label => $_} for @$rows;
+       $_ = ref $_ eq 'HASH' ? {%$_} : {label => $_} for @$rows;
        if (defined $checked) {
                if (ref $checked eq 'ARRAY') {
                        $rows->[$_]->{checked} = $checked->[$_] for 0 .. $#$rows;