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

Form id (html attribute id) collision when forms are loaded in AJAX - all forms have id="mform1"

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide
      1. Open any page with a form, like the one editing a forum activity, and inspect the HTML on the form
      2. Make sure "id" attribute on the form has random suffix, for example <form autocomplete="off" action="modedit.php" method="post" accept-charset="utf-8" id="mform1_mhoRiZnTCgAddbg" class="mform">

      Additionally, CiBoT should run all behat tests.

      Show
      Open any page with a form, like the one editing a forum activity, and inspect the HTML on the form Make sure "id" attribute on the form has random suffix, for example <form autocomplete="off" action="modedit.php" method="post" accept-charset="utf-8" id=" mform1_mhoRiZnTCgAddbg " class="mform"> Additionally, CiBoT should run all behat tests.
    • Affected Branches:
      MOODLE_36_STABLE
    • Fixed Branches:
      MOODLE_37_STABLE
    • Pull Master Branch:
      MDL-64324-master

      Description

      MoodleQuickForm constructor assigns "id" attribute to the forms with the following logic:

              static $formcounter = 1;
              if (is_null($this->getAttribute('id'))) {
                  $attributes['id'] = 'mform' . $formcounter;
              }
              $formcounter++;
      

      As a result all forms loaded in AJAX using Fragment API have the same id="mform1"

      This causes JS conflicts on the page

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  20/May/19

                  Time Tracking

                  Estimated:
                  Original Estimate - 0 minutes
                  0m
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 10 minutes
                  10m