- $attributes{onclick} = "if (confirm('" . delete($attributes{confirm}) . "')) return true; else return false;" if $attributes{confirm};
-
- return $self->input_tag($name, $value, %attributes, type => 'submit', class => 'submit');
-}
-
-sub button_tag {
- my ($self, $onclick, $value, @slurp) = @_;
- my %attributes = _hashify(@slurp);
-
- $attributes{id} ||= $self->name_to_id($attributes{name}) if $attributes{name};
- $attributes{type} ||= 'button';
-
- return $self->html_tag('input', undef, %attributes, value => $value, onclick => $onclick);
-}
-
-sub options_for_select {
- my $self = shift;
- my $collection = shift;
- my %options = _hashify(@_);
-
- my $value_key = $options{value} || 'id';
- my $title_key = $options{title} || $value_key;
-
- my $value_sub = $options{value_sub};
- my $title_sub = $options{title_sub};
-
- my $value_title_sub = $options{value_title_sub};
-
- my %selected = map { ( $_ => 1 ) } @{ ref($options{default}) eq 'ARRAY' ? $options{default} : defined($options{default}) ? [ $options{default} ] : [] };
-
- my $access = sub {
- my ($element, $index, $key, $sub) = @_;
- my $ref = ref $element;
- return $sub ? $sub->($element)
- : !$ref ? $element
- : $ref eq 'ARRAY' ? $element->[$index]
- : $ref eq 'HASH' ? $element->{$key}
- : $element->$key;
- };
-
- my @elements = ();
- push @elements, [ undef, $options{empty_title} || '' ] if $options{with_empty};
- push @elements, map [
- $value_title_sub ? @{ $value_title_sub->($_) } : (
- $access->($_, 0, $value_key, $value_sub),
- $access->($_, 1, $title_key, $title_sub),
- )
- ], @{ $collection } if $collection && ref $collection eq 'ARRAY';
-
- my $code = '';
- foreach my $result (@elements) {
- my %attributes = ( value => $result->[0] );
- $attributes{selected} = 'selected' if $selected{ defined($result->[0]) ? $result->[0] : '' };
-
- $code .= $self->html_tag('option', _H($result->[1]), %attributes);
- }
-
- return $code;
-}
-
-sub javascript {
- my ($self, $data) = @_;
- return $self->html_tag('script', $data, type => 'text/javascript');