use Test::More;
-plan tests => 50;
+plan tests => 55;
use_ok('HTML::Form::Simple');
'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'
+);
+
+is_deeply(
+ [ $form->hidden(foo => [1, 0], {class => 'test'}) ],
+ [
+ '<input class="test" name="foo" type="hidden" value="1">',
+ '<input class="test" name="foo" type="hidden" value="0">',
+ ],
+ 'hidden array'
+);
+
+is_deeply(
+ [ $form->hidden({2 => 0, 10 => 1}, {class => 'test'}) ],
+ [
+ '<input class="test" name="10" type="hidden" value="1">',
+ '<input class="test" name="2" type="hidden" value="0">',
+ ],
+ 'hidden hash'
+);
+
+{
+ local $, = "\n";
+ is(
+ scalar $form->hidden({2 => [1, 0], 10 => 2}, {class => 'test'}),
+ join("\n",
+ '<input class="test" name="10" type="hidden" value="2">',
+ '<input class="test" name="2" type="hidden" value="1">',
+ '<input class="test" name="2" type="hidden" value="0">',
+ ),
+ 'scalar hiddens'
+ );
+}
# submit
);
is(
- $form->radio(foo => undef, [2]), #TODO
+ $form->radio(foo => undef, 2),
'<input id="foo_2" name="foo" type="radio" value="2">',
'labelless radio'
);
'multiple checked checkboxes'
);
+{
+ local $, = ' | ';
+ is(
+ scalar $form->check(foo => [1, 0], {value => 0}),
+ join(' | ',
+ '<label><input id="foo_1" name="foo" type="checkbox" value="1"> 1</label>',
+ '<label><input id="foo_2" name="foo" type="checkbox" value="2"> 0</label>',
+ ),
+ 'merged checkboxes'
+ );
+}
+
is_deeply(
[ $form->check(undef, [{value => 4, type => 'radio'}], [1, 0, 0], {value => 3}) ],
[