XXX: hidden options
authorMischa Poslawsky <mischa@mediadesign.nl>
Fri, 25 Jul 2008 23:10:17 +0000 (01:10 +0200)
committerMischa Poslawsky <mischa@mediadesign.nl>
Fri, 25 Jul 2008 23:23:15 +0000 (01:23 +0200)
lib/HTML/Form/Simple.pm
t/html.t

index 4eddc98188b7c543653465b52347dbc8fb1ee431..66958c3c294d760d7729474a4ba829de9e3e1b10 100644 (file)
@@ -71,8 +71,9 @@ sub hidden {
        my $self = shift;
        my ($name, $value, $attr) = $self->_attr(2, @_);
 
-       $attr = {type => 'hidden', name => $name, value => $value};
-       #TODO: $attr
+       $attr->{name } = $name  if defined $name;
+       $attr->{value} = $value if defined $value;
+       $attr->{type} = 'hidden' unless defined $attr->{type};
 
        return $self->tag(input => $attr);
 }
index c646cdb9810cbcb60314445f6cb2d3c8284825f5..e5abb9ac5ac34e2e4550dc4c52e4d590043ff1b6 100644 (file)
--- a/t/html.t
+++ b/t/html.t
@@ -5,7 +5,7 @@ use warnings;
 
 use Test::More;
 
-plan tests => 50;
+plan tests => 51;
 
 use_ok('HTML::Form::Simple');
 
@@ -52,7 +52,11 @@ is(
        'hidden'
 );
 
-#TODO: hidden options
+is(
+       $form->hidden(undef, undef, {value => 'bar', name => 'foo', id => 'foo'}),
+       '<input id="foo" name="foo" type="hidden" value="bar">',
+       'hidden options'
+);
 
 # submit