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

Dynamic forms use the same id for different date elements

XMLWordPrintable

    • WP Sprint 2023-I4.2 (Clones)

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

       

        1. custom_course_fields_masterbranch.png
          209 kB
          Sujith Haridasan
        2. fig1201.png
          11 kB
          Amaia Anabitarte
        3. MDL-71336.png
          386 kB
          Ron Carl Alfon Yu

            pholden Paul Holden
            bawjaws David Scotson
            Odei Alba Odei Alba
            Huong Nguyen Huong Nguyen
            Ron Carl Alfon Yu Ron Carl Alfon Yu
            Votes:
            0 Vote for this issue
            Watchers:
            18 Start watching this issue

              Created:
              Updated:
              Resolved:

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

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