Skip to content

Commit 167e3a1

Browse files
ycerutojaviereguiluz
authored andcommitted
confirmation message now listen from submit event of the form
1 parent fd91b05 commit 167e3a1

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

app/Resources/views/admin/blog/_form.html.twig

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66
{{ form_start(form, { attr: { novalidate: 'novalidate' } }) }}
77
#}
88

9-
{{ form_start(form) }}
9+
{% if confirmation_message is defined %}
10+
{% set attr = {'data-confirmation-message': confirmation_message} %}
11+
{% endif %}
12+
13+
{{ form_start(form, {attr: attr|default({})}) }}
1014
{{ form_widget(form) }}
1115

1216
<input type="submit" value="{{ button_label|default('label.create_post'|trans) }}"

app/Resources/views/base.html.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@
155155
$(document).ready(function() {
156156
hljs.initHighlightingOnLoad();
157157
158-
$('[data-toggle="confirmation"][data-message]').on('click', function (event) {
159-
var message = $(this).data('message');
158+
$('form[data-confirmation-message]').on('submit', function (event) {
159+
var message = $(this).data('confirmation-message');
160160
161161
if (confirm(message) === false) {
162162
//cancel the event

0 commit comments

Comments
 (0)