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

Some form elements do not get defaults set when adding to repeat elements

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.6, 3.9
    • Fix Version/s: 3.9
    • Component/s: Forms Library
    • Labels:
    • Testing Instructions:
      Hide
      1. Place the attached PHP file into the root directory of your Moodle code base.
      2. Visit [siteurl]/formtest.php.
      3. Click on 'Add repeats'.
      • Confirm that all the newly-created repeat elements have the expected default values.
      • Confirm that any form elements changed before clicking on 'Add repeats' retain their updated values (whilst the new elements still gain the default values).
      Show
      Place the attached PHP file into the root directory of your Moodle code base. Visit [siteurl] /formtest.php. Click on 'Add repeats'. Confirm that all the newly-created repeat elements have the expected default values. Confirm that any form elements changed before clicking on 'Add repeats' retain their updated values (whilst the new elements still gain the default values).
    • Affected Branches:
      MOODLE_26_STABLE, MOODLE_39_STABLE
    • Fixed Branches:
      MOODLE_39_STABLE
    • Pull from Repository:
    • Pull Master Branch:

      Description

      Certain elements ignore the default values when the 'add' button is clicked within a repeating elements section.

      The elements that this affects are (assuming I haven't missed any):

      • checkbox
      • date_selector
      • date_time_selector
      • duration
      • tags

      This is due to each of these ignoring the default value and only accepting the 'submitted' value, in cases whereby the form is marked as 'submitted'. This usually makes sense, as any of these could legitimately have been changed to 'no value' before the form was submitted, and that should be reflected in the data.

      Unfortunately, when a new element is created via the 'add' button click, there is no submitted value, the default is also ignored, so the element ends up with the hard-coded default value.

      (See attached script for a quick demo - click on the 'Add repeats' button and compare the values in the second repeat with the defaults listed in the labels).

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              davosmith Davo Smith
              Reporter:
              davosmith Davo Smith
              Peer reviewer:
              Tim Hunt Tim Hunt
              Integrator:
              Andrew Lyons Andrew Lyons
              Tester:
              Andrew Lyons Andrew Lyons
              Participants:
              Component watchers:
              Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias, Sujith Haridasan
              Votes:
              1 Vote for this issue
              Watchers:
              8 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                15/Jun/20

                  Time Tracking

                  Estimated:
                  Original Estimate - 0 minutes
                  0m
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 4 hours, 11 minutes
                  4h 11m