From a30ad33e728864dfc626a0a74cda0269ade0ccfb Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Mon, 27 Dec 2010 13:49:09 +0100 Subject: [PATCH] submit_tag: JavaScript-Confirm erfragen, wenn Parameter confirm gesetzt ist --- SL/Template/Plugin/L.pm | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/SL/Template/Plugin/L.pm b/SL/Template/Plugin/L.pm index ac31e3104..479c4b859 100644 --- a/SL/Template/Plugin/L.pm +++ b/SL/Template/Plugin/L.pm @@ -148,7 +148,14 @@ sub hidden_tag { } sub submit_tag { - return shift->input_tag(@_, type => 'submit', class => 'submit'); + my $self = shift; + my $name = shift; + my $value = shift; + my %attributes = _hashify(@_); + + $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 options_for_select { @@ -328,6 +335,11 @@ Creates a HTML 'input type=submit class=submit' tag named C<$name> with the value C<$value> and with arbitrary HTML attributes from C<%attributes>. The tag's C defaults to C. +If C<$attributes{confirm}> is set then a JavaScript popup dialog will +be added via the C handler asking the question given with +C<$attributes{confirm}>. If request is only submitted if the user +clicks the dialog's ok/yes button. + =item C Creates a HTML 'textarea' tag named C<$name> with the content -- 2.20.1