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

    • MOODLE_36_STABLE
    • MOODLE_37_STABLE
    • MDL-64324-master
    • 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.

    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

              marina Marina Glancy
              marina Marina Glancy
              Mihail Geshoski Mihail Geshoski
              Sara Arjona (@sarjona) Sara Arjona (@sarjona)
              Anna Carissa Sadia Anna Carissa Sadia
              David Woloszyn, Huong Nguyen, Jake Dallimore, Meirza, Michael Hawkins, Raquel Ortega, Safat Shahin, Stevani Andolo, David Woloszyn, Huong Nguyen, Jake Dallimore, Meirza, Michael Hawkins, Raquel Ortega, Safat Shahin, Stevani Andolo
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                20/May/19

                Time Tracking

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