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

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

      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

            marina Marina Glancy
            marina Marina Glancy
            Mihail Geshoski Mihail Geshoski
            Sara Arjona (@sarjona) Sara Arjona (@sarjona)
            Anna Carissa Sadia Anna Carissa Sadia
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved:

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

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