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

admin_setting_configselect optgroups does not work

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.3.4, 3.4.1, 3.5
    • Fix Version/s: 3.3.6, 3.4.3
    • Component/s: Administration
    • Labels:
    • Testing Instructions:
      Hide

      Possibility to define option groups in admin_setting_configselect is implemented but not used in core. In order to test this issue you need to modify code.

      1. Search code for admin_setting_configselect and find definition of any setting that has options
      2. Login as admin and find this setting in Site administration, remember where and how it is displayed
      3. Modify code similar to this:

      - $temp->add(new admin_setting_configselect('qwerty', 'NAME', 'DESCRIPTION', 'defvalue', $options);
      + $temp->add(new admin_setting_configselect('qwerty', 'NAME', 'DESCRIPTION', 'defvalue', ['optionsgroup' => $options]);
      

      (you can use multiple option groups if you want)
      4. Login as admin and find this setting in Site administration
      5. Make sure the setting is displayed and all options are present, the options appear in the option group

      Show
      Possibility to define option groups in admin_setting_configselect is implemented but not used in core. In order to test this issue you need to modify code. 1. Search code for admin_setting_configselect and find definition of any setting that has options 2. Login as admin and find this setting in Site administration, remember where and how it is displayed 3. Modify code similar to this: - $temp->add(new admin_setting_configselect('qwerty', 'NAME', 'DESCRIPTION', 'defvalue', $options); + $temp->add(new admin_setting_configselect('qwerty', 'NAME', 'DESCRIPTION', 'defvalue', ['optionsgroup' => $options]); (you can use multiple option groups if you want) 4. Login as admin and find this setting in Site administration 5. Make sure the setting is displayed and all options are present, the options appear in the option group
    • Affected Branches:
      MOODLE_33_STABLE, MOODLE_34_STABLE, MOODLE_35_STABLE
    • Fixed Branches:
      MOODLE_33_STABLE, MOODLE_34_STABLE
    • Pull Master Branch:

      Description

      In admin_setting_configselect the "choices" property is not correctly initialize which cause the following error when using optgroups and make the select non functional.

      Warning: array_merge(): Argument #1 is not an array in /home/test/www/moodle/lib/adminlib.php on line 2966

        Attachments

          Activity

            People

            • Assignee:
              ak4t0sh Arnaud Trouvé
              Reporter:
              ak4t0sh Arnaud Trouvé
              Peer reviewer:
              Marina Glancy
              Integrator:
              Eloy Lafuente (stronk7)
              Tester:
              Eloy Lafuente (stronk7)
              Participants:
              Component watchers:
              Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
            • Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                17/May/18