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

Tricky to set a type on elements within a named group inside repeated elements (backport of MDL-39579)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • 2.3.8, 2.4.5
    • 2.2.9, 2.3.6, 2.4.3
    • Forms Library
    • MOODLE_22_STABLE, MOODLE_23_STABLE, MOODLE_24_STABLE
    • MOODLE_23_STABLE, MOODLE_24_STABLE
    • Hide

      Focus on groups within repeated elements

      1. Run the Unit Tests
      2. Play with attached file test_form_validation.php
        • Make sure the warnings displayed are expected
        • Make sure the expected warnings are displayed
        • Make sure the submitted values are cleaned properly
      3. Search for groups in repeated elements
        • Make sure they work as expected
      Show
      Focus on groups within repeated elements Run the Unit Tests Play with attached file test_form_validation.php Make sure the warnings displayed are expected Make sure the expected warnings are displayed Make sure the submitted values are cleaned properly Search for groups in repeated elements Make sure they work as expected

      The magic in $mform->repeat_elements() does not allow for the developer to set a type on an element within a (named?) group.

      The following code doesn't work:

                  $group = array(
                      $mform->createElement('text', 'repeatedgroupel1', 'repeatedgroupel1'),
                      $mform->createElement('text', 'repeatedgroupel2', 'repeatedgroupel2'));
                  $repeat = $mform->createElement('group', 'mygroup', 'mygroup', $group);
                  $this->repeat_elements(array($repeat), 2, array('mygroup[repeatedgroupel1]' => array('type' => PARAM_INT)),
                      'repeteablegroup', 'add', 0);
      

            fred Frédéric Massart
            poltawski Dan Poltawski
            Adrian Greeve Adrian Greeve
            Marina Glancy Marina Glancy
            Jason Fowler Jason Fowler
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

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