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

Duration form element does not return the values in the correct format (when used in arrays)

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide
      1. Upload the attached test file to wwwroot
      2. Open testform.php in the browser
      3. Type something in the form and submit it
      4. Make sure you see the submitted values as nested arrays and the structure of array is the same for text element and duration element
      5. For regression test: create a lesson activity in any course
      6. Change the "Time limit" in the module settings
      7. Save and re-open the module setting form
      8. Make sure the "Time limit" is set to the same value as you set it before
      Show
      Upload the attached test file to wwwroot Open testform.php in the browser Type something in the form and submit it Make sure you see the submitted values as nested arrays and the structure of array is the same for text element and duration element For regression test: create a lesson activity in any course Change the "Time limit" in the module settings Save and re-open the module setting form Make sure the "Time limit" is set to the same value as you set it before
    • Affected Branches:
      MOODLE_37_STABLE
    • Fixed Branches:
      MOODLE_36_STABLE, MOODLE_37_STABLE
    • Pull 3.7 Branch:
    • Pull Master Branch:
      MDL-67084-master

      Description

      There is a function _prepareValue() that must be used in form elements exportValue() and it is not always used.

      For example,

              $mform->addElement('text', 'eltext[0]', 'extext');
              $mform->addElement('duration', 'elduration[0]', 'elduration');
      

      Will result in the $data object:

      stdClass Object
      (
          [eltext] => Array
              (
                  [0] => 
              )
       
          [elduration[0]] => 0
          [submitbutton] => Save changes
      )
      

      See the attached testform.php

      We want to use "duration" element inside repeated elements and it gives inconsistent result to the other elements.

      There is also 'modgrade' element that does not call _prepareValue() however it can only be used inside the activity module edit form and it's too complicated to try to fix

        Attachments

          Activity

            People

            Assignee:
            marina Marina Glancy
            Reporter:
            marina Marina Glancy
            Peer reviewer:
            Daniel Neis Araujo
            Integrator:
            Jun Pataleta
            Tester:
            Janelle Barcega
            Participants:
            Component watchers:
            Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              11/Nov/19

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 2 hours, 1 minute
                2h 1m