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

Dynamic forms use the same id for different date elements

    XMLWordPrintable

    Details

    • Affected Branches:
      MOODLE_310_STABLE, MOODLE_311_STABLE, MOODLE_400_STABLE

      Description

      === Updated description (for Moodle LMS) ===
      When random ids are used in moodle forms, all date elements have the same ids.
      To reproduce on 3.11 and master:

      • Go to Site administration>Courses>Custom course fields
      • Add a new custom field with the type "Date and time"
      • inspect the HTML of the form elements for "day", "month", "year" in the "Minimum value" line - they all have the same "id" attribute

      This happens in any form that uses random ids. Random ids were introduced in MDL-65217 by the workplace team and they are only used in Moodle LMS from 3.11, however the error is present in the previous version of Moodle too.

      === Original description (for Moodle Workplace) ===

      I've not quite exactly tracked down where this is going wrong but the symptoms are:

      On pages such as:
      admin/tool/dynamicrule/rule.php

      When there's a date selector visible, the same id is repeatedly used for the different component parts of the component, e.g. the day, month and year selects and the checkbox will all have an id of id_jobstartdate_qpuEszZ9BCWsRow.

      I think the id_error_jobstartdate_bLahBlAh is also repeated.

      On a moodle I checked, a similar control has unique names for each item, like:

      id_enddate_day/month/year/enabled,

      but I think these are perhaps just two different form libraries, so possibly this bug is shared with Moodle, but not spotted it anywhere there yet.

      I'm thinking this may be an accessability issue (as labels are linked to the item they reference via the id, as well as potentially confusing the JS that is set to run on errors, as well as being a HTML validation issue.

       

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              bawjaws David Scotson
              Participants:
              Component watchers:
              Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias, Sujith Haridasan
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated: