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

Modal forms - not possible to pass arrays as arguments

    XMLWordPrintable

Details

    • MOODLE_311_STABLE, MOODLE_400_STABLE
    • MOODLE_311_STABLE, MOODLE_400_STABLE
    • MDL-71686-master
    • Hide
      1. Install a plugin from https://github.com/marinaglancy/moodle-local_modalformexamples (if you installed it earlier - update it to the latest version)
      2. Go to Site administration>Development>Modal form examples
      3. Open browser console, make sure no errors related to modal forms appear in the console during the test
      4. Navigate to test 2: try opening form clicking both links (with and without data), make sure values populate for the name and two options
      5. Navigate to test 4: try opening form with and without arguments, make sure arguments populate for the name and two options
      Show
      Install a plugin from https://github.com/marinaglancy/moodle-local_modalformexamples (if you installed it earlier - update it to the latest version) Go to Site administration>Development>Modal form examples Open browser console, make sure no errors related to modal forms appear in the console during the test Navigate to test 2: try opening form clicking both links (with and without data), make sure values populate for the name and two options Navigate to test 4: try opening form with and without arguments, make sure arguments populate for the name and two options

    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

        1. 4_v400_MDL-71686.png
          4_v400_MDL-71686.png
          102 kB
        2. 4_v311_MDL-71686.png
          4_v311_MDL-71686.png
          92 kB
        3. 4_master_MDL-71686.png
          4_master_MDL-71686.png
          129 kB
        4. 3_v400_MDL-71686.png
          3_v400_MDL-71686.png
          104 kB
        5. 3_v311_MDL-71686.png
          3_v311_MDL-71686.png
          91 kB
        6. 3_master_MDL-71686.png
          3_master_MDL-71686.png
          128 kB
        7. 2_v400_MDL-71686.png
          2_v400_MDL-71686.png
          103 kB
        8. 2_v311_MDL-71686.png
          2_v311_MDL-71686.png
          88 kB
        9. 2_master_MDL-71686.png
          2_master_MDL-71686.png
          149 kB
        10. 1_v400_MDL-71686.png
          1_v400_MDL-71686.png
          88 kB
        11. 1_v311_MDL-71686.png
          1_v311_MDL-71686.png
          90 kB
        12. 1_master_MDL-71686.png
          1_master_MDL-71686.png
          150 kB

        Issue Links

          Activity

            People

              marina Marina Glancy
              marina Marina Glancy
              Stevani Andolo Stevani Andolo
              Andrew Lyons Andrew Lyons
              John Edward Pedregosa John Edward Pedregosa
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - 0 minutes
                  0m
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 5 hours, 14 minutes
                  5h 14m

                  Clockify

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