Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-80604

In the Ajaxforms (dynamc_form class) the identifier of the clicked submit Button is not added

XMLWordPrintable

    • 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!

            Unassigned Unassigned
            georgmaisser Georg Maißer
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.