XXX: row method
[perl/html-form-simple.git] / lib / HTML / Form / Simple.pm
index 7d023146eef48d65c69bb858dff5fe50b5c317bf..a72215122ed92c349ac329f539932cdf2b157136 100644 (file)
@@ -33,7 +33,7 @@ sub tag {
 
        # strip empty if it shouldn't be
        defined $attr->{$_} and $attr->{$_} eq '' and delete $attr->{$_}
-               for qw(id type class style);
+               for qw(id for type class style);
 
        my $return = '<' . $tag;
 
@@ -248,6 +248,24 @@ sub check {
        $self->select($name, $rows, {%$attr, type => 'checkbox'});
 }
 
+sub row {
+       my $self = shift;
+       my ($name, $contents, $attr) = $self->_attr(2, @_);
+
+       $contents = defined $contents && ref $contents ne 'HASH'
+               ? $self->quote($contents) : $self->text($name, $contents);
+       my $label = defined $attr->{label}
+               ? $self->quote(delete $attr->{label})
+               : defined $name ? $self->quote($name) : '';
+
+       return $self->tag(label => {for => $name, %$attr})
+               . $label
+               . '</label>'
+               . (defined $, ? $, : ' ')
+               . $contents
+               ;
+}
+
 1;
 
 __END__