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

QuickForm insertElementBefore shows a warning if there are multiple elements without a name

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.9.13, 2.0.4, 2.1.1
    • Fix Version/s: 2.1.6, 2.2.3
    • Component/s: Forms Library
    • Labels:
    • Testing Instructions:
      Hide

      At the end of course/edit_form.php function 'definition()' add the following line:
      $mform->insertElementBefore($mform->createElement('static', 'testing', 'This is a test', 'The test text'), 'idnumber');

      The element appears as expected, but there is also the following error message:
      Notice: Undefined index: in [folder-removed]/lib/pear/HTML/QuickForm.php on line 679
      Warning: array_search() expects parameter 2 to be array, null given in[folder-removed]/lib/pear/HTML/QuickForm.php on line 679

      Show
      At the end of course/edit_form.php function 'definition()' add the following line: $mform->insertElementBefore($mform->createElement('static', 'testing', 'This is a test', 'The test text'), 'idnumber'); The element appears as expected, but there is also the following error message: Notice: Undefined index: in [folder-removed] /lib/pear/HTML/QuickForm.php on line 679 Warning: array_search() expects parameter 2 to be array, null given in [folder-removed] /lib/pear/HTML/QuickForm.php on line 679
    • Affected Branches:
      MOODLE_19_STABLE, MOODLE_20_STABLE, MOODLE_21_STABLE
    • Fixed Branches:
      MOODLE_21_STABLE, MOODLE_22_STABLE
    • Pull Master Branch:
      MDL-29147_insertElementBefore_warning

      Description

      When adding an element, the duplicates array is not updated if the element has no name.
      However, when using the 'insertElementBefore' function, it is assumed that all duplicate elements are contained in the duplicates array.

      I've attached the one-line patch.

      Note the test below uses the course edit form for convenience, as it is already set up, but this will affect any forms with multiple unnamed entries.

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  14/May/12