use Test::More;
-plan tests => 43;
+plan tests => 47;
use_ok('HTML::Form::Simple');
);
is(
- $form->input('', '', {disabled => 0, something => undef, class => undef, style => ''}),
+ $form->input('', '', {
+ disabled => 0,
+ something => undef,
+ class => undef,
+ style => '',
+ name => 'ignore',
+ value => 'overrides',
+ }),
'<input name="" type="text" value="">',
'input with empty attributes'
);
is(
- $form->input(undef, undef, {name => 'override', value => 'override'}),
- '<input type="text">',
- 'ignore input overrides'
+ $form->input(undef, undef, {name => '0', value => '0'}),
+ '<input id="0" name="0" type="text" value="0">',
+ 'input overrides'
);
is(
);
is(
- $form->radio(foo => 1),
- '<input id="foo_1" name="foo" type="radio" value="1">',
+ $form->radio(foo => 'test'),
+ '<label><input id="foo_1" name="foo" type="radio" value="1"> test</label>',
'radio method'
);
+is(
+ $form->radio(foo => undef, [2]), #TODO
+ '<input id="foo_2" name="foo" type="radio" value="2">',
+ 'labelless radio'
+);
+
is(
$form->radio(undef, {checked => 1}),
'<input checked type="radio">',
'simple radio button'
);
+is_deeply(
+ [ $form->radio(undef, ['', '<">']) ],
+ [
+ '<input type="radio" value="1">',
+ '<label><input type="radio" value="2"> <"></label>',
+ ],
+ 'multiple radios'
+);
+
+is_deeply(
+ [ $form->radio(foo => 'test', ['foo', ''], {value => '', id => ''}) ],
+ [
+ '<label><input name="foo" type="radio" value="foo"> test</label>',
+ '<label><input checked name="foo" type="radio" value=""> test</label>',
+ ],
+ 'multiple radios with custom value'
+);
+
+is_deeply(
+ [ $form->radio(foo => ['', 0], [0, 1, '']) ],
+ [
+ '<input id="foo_0" name="foo" type="radio" value="0">',
+ '<label><input id="foo_1" name="foo" type="radio" value="1"> 0</label>',
+ '<input id="foo_" name="foo" type="radio" value="">',
+ ],
+ 'multiple radios with custom values'
+);
+
+# check
+
is(
$form->check('foo'),
'<input id="foo_1" name="foo" type="checkbox" value="1">',