sub radio {
my $self = shift;
- my ($name, $label, $rows, $attr) = $self->_attr(3, @_);
+ my ($name, $rows, $label, $attr) = $self->_attr(3, @_);
if (not defined $rows) {
if (defined $label) {
msg => 'Textarea default', {rows => 4, style => 'background:red'}
) ],
[ Gender => join ' or ', $input->radio(
- sex => ['m', 'f']
+ sex => [qw(m f)], [qw(Male Female)]
) ],
[ Colour => scalar $input->select(
favcolour => [qw(Blue Green Red)], 'Green'
=over
-=item C<radio>|C<check> parameter order
-
-Row options (hash ref details) are inconsistent:
-on labels for C<check>, on values for C<radio>.
-Make behaviour more logical.
-
=item C<default()> method
$input->hidden(foo => $input->default('foo'));
use Test::More;
-plan tests => 65;
+plan tests => 66;
use_ok('HTML::Form::Simple');
is(
$form->radio(foo => 'test'),
- '<label><input id="foo_1" name="foo" type="radio" value="1"> test</label>',
+ '<input id="foo_test" name="foo" type="radio" value="test">',
'radio method'
);
is(
- $form->radio(foo => undef, 2),
- '<input id="foo_2" name="foo" type="radio" value="2">',
- 'labelless radio'
+ $form->radio(foo => undef, 'test'),
+ '<label><input id="foo_1" name="foo" type="radio" value="1"> test</label>',
+ 'labeled radio'
);
is(
is_deeply(
[ $form->radio(undef, ['', '<">']) ],
+ [
+ '<input type="radio" value="">',
+ '<input type="radio" value="<">">',
+ ],
+ 'multiple radios'
+);
+
+is_deeply(
+ [ $form->radio(undef, undef, ['', '<">']) ],
[
'<input type="radio" value="1">',
'<label><input type="radio" value="2"> <"></label>',
],
- 'multiple radios'
+ 'multiple radio labels'
);
is_deeply(
- [ $form->radio(foo => 'test', ['foo', ''], {value => '', id => ''}) ],
+ [ $form->radio(foo => ['foo', ''], 'test', {value => '', id => ''}) ],
[
'<label><input name="foo" type="radio" value="foo"> test</label>',
'<label><input checked name="foo" type="radio" value=""> test</label>',
);
is_deeply(
- [ $form->radio(foo => ['', 0], [0, 1, '']) ],
+ [ $form->radio(foo => [0, 1, ''], ['', 0]) ],
[
'<input id="foo_0" name="foo" type="radio" value="0">',
'<label><input id="foo_1" name="foo" type="radio" value="1"> 0</label>',
{
# make sure arguments aren't modified
- my @args = (foo => [0, 1], [0, {value => 1}], {name => 0, value => 1});
- my @orgs = (foo => [0, 1], [0, {value => 1}], {name => 0, value => 1});
+ my @args = (foo => [0, {value => 1}], [0, 1], {name => 0, value => 1});
+ my @orgs = (foo => [0, {value => 1}], [0, 1], {name => 0, value => 1});
my @output = (
'<label><input id="foo_0" name="foo" type="radio" value="0"> 0</label>',
'<label><input checked id="foo_1" name="foo" type="radio" value="1"> 1</label>',
[ $form->check(@args) ],
[
'<label><input checked id="foo_1" name="foo" type="checkbox" value="1"> 0</label>',
- '<label><input checked id="foo_2" name="foo" type="checkbox" value="2"> 1</label>',
+ '<input checked id="foo_1" name="foo" type="checkbox" value="1">',
],
'options var to check'
);
);
is_deeply(
- [ $defform->radio(0 => undef, [1, 0]) ],
+ [ $defform->radio(0 => [1, 0]) ],
[
'<input id="0_1" name="0" type="radio" value="1">',
'<input checked id="0_0" name="0" type="radio" value="0">',