-1

I want to submit a Form after a checkbox is changed in a twig file like:

{{start_form(einrichtungUsersForm.getEinrichtungUserType())}}
{{ form_widget(einrichtungUsersForm.getEinrichtungUserType().active )}}
{{ende_form(einrichtungUsersForm.getEinrichtungUserType())}}

Is that possible?

DarkBee
  • 16,592
  • 6
  • 46
  • 58
  • Yes it’s, Search for Ajax on change function –  Dec 16 '21 at 14:26
  • [related](https://stackoverflow.com/questions/13840429/what-is-the-difference-between-client-side-and-server-side-programming) – DarkBee Dec 16 '21 at 15:26

1 Answers1

0

yes you can do it with jquery like this :

$('body').on('change', '#checkboxId', function() {
    $(this).closest('form').submit();
});

If you don't use jquery, this is the solution with javascript :

let checkbox = document.getElementById('checkboxId');
checkbox.addEventListener('change' => () {
    this.closest('form').submit();
});
Abdelhak ouaddi
  • 474
  • 2
  • 4