-
Improvement
-
Resolution: Unresolved
-
Minor
-
None
-
4.4
-
MOODLE_404_STABLE
When clicking a no submit Button in a dynamic form, the identifier of the button becomes part of the ajaxformdata and we can react on this.
This is not true for the submit Buttons. If there are more than one submit buttons, the information, which one was clicked, is lost.
As it was possible in the legacy form, to have more than one submit buttons, it should also be possible in the new dynamic form.
There is an easy, three lines fix for that:
In dynamicform.js line 126, instead of
this.submitFormAjax(); |
submit the submitter.
this.submitFormAjax(e.submitter); |
Then in the submitFomAjax function, accept the button as param and add below the line
const formData = new URLSearchParams([...(new FormData(form)).entries()]); |
add this:
formData.append(button.getAttribute('name'), button.getAttribute('value')); |
The concept is similarly already implemented for the nosubmit button, so there should be no issue with just adding this code.
I will try to add a pull request for this, but not sure I will manage soon, so if anybody else will want to do this, you are welcome!
Thank you!