my $content = shift;
my $attributes = $self->attributes(@_);
- return "<${tag}${attributes}/>" unless $content;
+ return "<${tag}${attributes}/>" unless defined($content);
return "<${tag}${attributes}>${content}</${tag}>";
}
return $self->html_tag('select', $options_str, %attributes, name => $name);
}
+sub textarea_tag {
+ my $self = shift;
+ my $name = shift;
+ my $content = shift;
+ my %attributes = _hashify(@_);
+
+ $attributes{id} ||= $self->name_to_id($name);
+ $content = $content ? '' : _H($content);
+
+ return $self->html_tag('textarea', $content, %attributes, name => $name);
+}
+
sub checkbox_tag {
my $self = shift;
my $name = shift;
return $code;
}
+sub radio_button_tag {
+ my $self = shift;
+ my $name = shift;
+ my %attributes = _hashify(@_);
+
+ $attributes{value} = 1 unless defined $attributes{value};
+ $attributes{id} ||= $self->name_to_id($name . "_" . $attributes{value});
+ my $label = delete $attributes{label};
+
+ if ($attributes{checked}) {
+ $attributes{checked} = 'checked';
+ } else {
+ delete $attributes{checked};
+ }
+
+ my $code = $self->html_tag('input', undef, %attributes, name => $name, type => 'radio');
+ $code .= $self->html_tag('label', $label, for => $attributes{id}) if $label;
+
+ return $code;
+}
+
sub input_tag {
my $self = shift;
my $name = shift;
C<$value> and with arbitrary HTML attributes from C<%attributes>. The
tag's C<id> defaults to C<name_to_id($name)>.
+=item C<textarea_tag $name, $value, %attributes>
+
+Creates a HTML 'textarea' tag named C<$name> with the content
+C<$value> and with arbitrary HTML attributes from C<%attributes>. The
+tag's C<id> defaults to C<name_to_id($name)>.
+
=item C<checkbox_tag $name, %attributes>
Creates a HTML 'input type=checkbox' tag named C<$name> with arbitrary
created with said C<label>. No attribute named C<label> is created in
that case.
-=item C<date_tag $name, $value, %attributes>
-
=item C<date_tag $name, $value, cal_align =E<gt> $align_code, %attributes>
Creates a date input field, with an attached javascript that will open a
the details, usually you'll want a two letter abbreviation of the alignment.
Right + Bottom becomes C<BL>.
+=item C<radio_button_tag $name, %attributes>
+
+Creates a HTML 'input type=radio' tag named C<$name> with arbitrary
+HTML attributes from C<%attributes>. The tag's C<value> defaults to
+C<1>. The tag's C<id> defaults to C<name_to_id($name . "_" . $value)>.
+
+If C<%attributes> contains a key C<label> then a HTML 'label' tag is
+created with said C<label>. No attribute named C<label> is created in
+that case.
+
=back
=head2 CONVERSION FUNCTIONS