summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
80de26e)
In scalar context, put $OUTPUT_FIELD_SEPARATOR ($,) between each option,
which under normal circumstances is unset, resulting in unaltered
behaviour. This allows custom formatting without the need for special
attribute options/misuse.
my @options = map { ref $_ ? $_ : {value => $_} } @$rows;
my @options = map { ref $_ ? $_ : {value => $_} } @$rows;
if ($attr->{type} eq 'select') {
delete $attr->{type};
if (defined $default) {
if ($attr->{type} eq 'select') {
delete $attr->{type};
if (defined $default) {
$_->{selected} = 1 if defined $_->{value} and $_->{value} eq $default;
}
}
$_->{selected} = 1 if defined $_->{value} and $_->{value} eq $default;
}
}
$self->tag(select => $attr),
(map { $self->tag(option => $_) } @options),
'</select>',
);
$self->tag(select => $attr),
(map { $self->tag(option => $_) } @options),
'</select>',
);
- return wantarray ? @return : join('', @return);
}
else {
if (defined $attr->{id} and $attr->{id} ne '') {
}
else {
if (defined $attr->{id} and $attr->{id} ne '') {
- defined $_->{id} or defined $_->{value} and $_->{id} = $attr->{id}.'_'.$_->{value}
- for @options;
+ defined $_->{id}
+ or defined $_->{value} and $_->{id} = $attr->{id}.'_'.$_->{value}
+ for @options;
}
if (defined $attr->{label}) {
defined $_->{value} and not defined $_->{label}
}
if (defined $attr->{label}) {
defined $_->{value} and not defined $_->{label}
}
}
$_ = {%$attr, %$_} for @options;
}
}
$_ = {%$attr, %$_} for @options;
my $label = delete $_->{label};
defined $label && $label ne ''
? '<label>'.$self->tag(input => $_)." $label</label>"
: $self->tag(input => $_)
} @options;
my $label = delete $_->{label};
defined $label && $label ne ''
? '<label>'.$self->tag(input => $_)." $label</label>"
: $self->tag(input => $_)
} @options;
- return wantarray ? @return : join('', @return);
+
+ return wantarray ? @return : join(defined $, ? $, : '', @return);
use_ok('HTML::Form::Simple');
use_ok('HTML::Form::Simple');
- $form->radio(foo => undef, [2]), #TODO
+ $form->radio(foo => undef, 2),
'<input id="foo_2" name="foo" type="radio" value="2">',
'labelless radio'
);
'<input id="foo_2" name="foo" type="radio" value="2">',
'labelless radio'
);
'multiple checked checkboxes'
);
'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}) ],
[
is_deeply(
[ $form->check(undef, [{value => 4, type => 'radio'}], [1, 0, 0], {value => 3}) ],
[