+sub checkbox_tag {
+ my ($self, $name, %attributes) = @_;
+
+ _set_id_attribute(\%attributes, $name);
+
+ $attributes{value} = 1 unless defined $attributes{value};
+ my $label = delete $attributes{label};
+ my $checkall = delete $attributes{checkall};
+ my $for_submit = delete $attributes{for_submit};
+
+ if ($attributes{checked}) {
+ $attributes{checked} = 'checked';
+ } else {
+ delete $attributes{checked};
+ }
+
+ my $code = '';
+ $code .= $self->hidden_tag($name, 0, %attributes, id => $attributes{id} . '_hidden') if $for_submit;
+ $code .= $self->html_tag('input', undef, %attributes, name => $name, type => 'checkbox');
+ $code .= $self->html_tag('label', $label, for => $attributes{id}) if $label;
+ $code .= $self->javascript(qq|\$('#$attributes{id}').checkall('$checkall');|) if $checkall;
+
+ return $code;
+}
+
+sub javascript {
+ my ($self, $data) = @_;
+ return $self->html_tag('script', $data, type => 'text/javascript');
+}
+
+sub _set_id_attribute {
+ my ($attributes, $name, $unique) = @_;
+
+ if (!delete($attributes->{no_id}) && !$attributes->{id}) {
+ $attributes->{id} = name_to_id(undef, $name);
+ $attributes->{id} .= '_' . $attributes->{value} if $unique;
+ }
+
+ return %{ $attributes };
+}
+
+my $html_restricter;
+
+sub restricted_html {
+ my ($self, $value) = @_;
+
+ $html_restricter ||= SL::HTML::Restrict->create;
+ return $html_restricter->process($value);
+}
+