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

Modal forms - not possible to pass arrays as arguments

    XMLWordPrintable

Details

    • Bug
    • Status: Waiting for peer review
    • Minor
    • Resolution: Unresolved
    • 3.11, 4.0
    • None
    • Forms Library

    Description

      When we started moving all workplace forms to https://docs.moodle.org/dev/Modal_and_AJAX_forms we found a couple of errors introduced during re-writing from jquery to ES6 and also when making changes during integration review:

      1. The error handler does not bind "this" and on submission error (for example, if there was an exception during processing), the notification is not displayed, instead there is a JS error "'this' is undefined"
      edit: this was fixed in MDL-73205

      2. It is not possible to pass arrays as arguments - they reach the form as comma-separated string

      const args = {programid: 15, programuserids: [15,2,3,8]};
      const searchParams = new URLSearchParams(Object.entries(args));
      console.log(searchParams.toString());
      // Actual: programid=15&programuserids=15%2C2%2C3%2C8
      // What we expect: programid=15&programuserids[]=15&programuserids[]=2&programuserids[]=3&programuserids[]=8
      

      Attachments

        Issue Links

          Activity

            People

              marina Marina Glancy
              marina Marina Glancy
              Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - 0 minutes
                  0m
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 2 hours, 10 minutes
                  2h 10m