forked from SymfonyCasts/symfony-ux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjquery-serialize-form-on-save.diff
27 lines (26 loc) · 1.05 KB
/
jquery-serialize-form-on-save.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
diff --git a/assets/controllers/modal-form_controller.js b/assets/controllers/modal-form_controller.js
index d51b37e..a92d888 100644
--- a/assets/controllers/modal-form_controller.js
+++ b/assets/controllers/modal-form_controller.js
@@ -15,4 +15,9 @@ export default class extends Controller {
this.modalBodyTarget.innerHTML = await $.ajax(this.formUrlValue);
}
+
+ submitForm() {
+ const $form = $(this.modalBodyTarget).find('form');
+ console.log($form.serialize());
+ }
}
diff --git a/templates/_modal.html.twig b/templates/_modal.html.twig
index 550a93a..7568515 100644
--- a/templates/_modal.html.twig
+++ b/templates/_modal.html.twig
@@ -19,7 +19,7 @@
<button type="button" class="btn btn-secondary"
data-bs-dismiss="modal">Cancel
</button>
- <button type="button" class="btn btn-primary">
+ <button type="button" class="btn btn-primary" data-action="modal-form#submitForm">
Save
</button>
</div>