From: Moritz Bunkus Date: Mon, 27 Dec 2010 12:49:09 +0000 (+0100) Subject: submit_tag: JavaScript-Confirm erfragen, wenn Parameter confirm gesetzt ist X-Git-Tag: release-2.6.2beta1~64^2~30 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=a30ad33e728864dfc626a0a74cda0269ade0ccfb;p=kivitendo-erp.git submit_tag: JavaScript-Confirm erfragen, wenn Parameter confirm gesetzt ist --- 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