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

Hide_if not working for filesize form element in site admin

XMLWordPrintable

    • MOODLE_39_STABLE
    • MOODLE_310_STABLE, MOODLE_39_STABLE
    • MDL-69748-master
    • Hide

      Test 1 (Moodle 3.10, 3.11 and master)

      1. Log in as admin
      2. Go to Site administration > Courses > Download course content
      3. Verify that deselecting the "Download course content feature available" field will hide the "Maximum size per file" field
      4. Verify that selecting the "Download course content feature available" field will show the "Maximum size per file" field

       Test 2 (Moodle 3.9)

      1. Open the /admin/settings/courses.php file in an editor
      2. Paste the following inside the first IF statement (right after the IF line), then save the file

        $temp = new admin_settingpage('testinghideif', 'Testing hide_if');
        $testvals = [0 => 'Hide children', 1 => 'Show children'];
        $temp->add(new admin_setting_configselect('parentsetting', 'Parent setting', 'Selecting "Hide children" should hide both.', 1, $testvals));
        $temp->add(new \core_admin\local\settings\filesize('childsetting1', 'Child setting 1', 'Bug - This will not hide when "Hide children" has been selected above.', 1024));
        $temp->add(new admin_setting_configcheckbox('childsetting2', 'Child setting 2', 'This will correctly be hidden.', 0));
        $temp->hide_if('childsetting1', 'parentsetting', 'eq', 0);
        $temp->hide_if('childsetting2', 'parentsetting', 'eq', 0);
         
        $ADMIN->add('courses', $temp);

      3. Bump up Moodle version in version.php and run Moodle upgrade
      4. Log in as admin
      5. Navigate to <wwwroot>/admin/settings.php?section=testinghideif
      6. Set to "Parent setting" to "Show children"
      7. Verify that you see 2 other settings: "Child setting 1" and "Child setting 2"
      8. Set to "Parent setting" to "Hide children"
      9. Verify that both child settings are hidden: "Child setting 1" and "Child setting 2"

       

       

      Show
      Test 1 (Moodle 3.10, 3.11 and master) Log in as admin Go to Site administration > Courses > Download course content Verify that deselecting the "Download course content feature available" field will hide the "Maximum size per file" field Verify that selecting the "Download course content feature available" field will show the "Maximum size per file" field  Test 2 (Moodle 3.9) Open the /admin/settings/courses.php file in an editor Paste the following inside the first IF statement (right after the IF line), then save the file $temp = new admin_settingpage('testinghideif', 'Testing hide_if'); $testvals = [0 => 'Hide children', 1 => 'Show children']; $temp->add(new admin_setting_configselect('parentsetting', 'Parent setting', 'Selecting "Hide children" should hide both.', 1, $testvals)); $temp->add(new \core_admin\local\settings\filesize('childsetting1', 'Child setting 1', 'Bug - This will not hide when "Hide children" has been selected above.', 1024)); $temp->add(new admin_setting_configcheckbox('childsetting2', 'Child setting 2', 'This will correctly be hidden.', 0)); $temp->hide_if('childsetting1', 'parentsetting', 'eq', 0); $temp->hide_if('childsetting2', 'parentsetting', 'eq', 0);   $ADMIN->add('courses', $temp); Bump up Moodle version in version.php and run Moodle upgrade Log in as admin Navigate to <wwwroot>/admin/settings.php?section=testinghideif Set to "Parent setting" to "Show children" Verify that you see 2 other settings: "Child setting 1" and "Child setting 2" Set to "Parent setting" to "Hide children" Verify that both child settings are hidden: "Child setting 1" and "Child setting 2"    
    • 4
    • International 4.0 - Sprint 7, Internationals - 3.11 Sprint 2, Internationals - 3.11 Sprint 3, Internationals - 3.11 Sprint 4, Internationals - 3.11 Sprint 5

      The hide_if function of adminlib appears to have no effect on filesize inputs, so those settings cannot be hidden based on the value of other settings.

      Steps to reproduce:

      1. Open the /admin/settings/courses.php file in your IDE.
      2. Paste the following inside the first IF statement (it can be the first thing inside the IF), then save the file:

            $temp = new admin_settingpage('testinghideif', 'Testing hide_if');
            $testvals = [0 => 'Hide children', 1 => 'Show children'];
            $temp->add(new admin_setting_configselect('parentsetting', 'Parent setting', 'Selecting "Hide children" should hide both.', 1, $testvals));
            $temp->add(new filesize('childsetting1', 'Child setting 1', 'Bug - This will not hide when "Hide children" has been selected above.', 1024));
            $temp->add(new admin_setting_configcheckbox('childsetting2', 'Child setting 2', 'This will correctly be hidden.', 0));
            $temp->hide_if('childsetting1', 'parentsetting', 'eq', 0);
            $temp->hide_if('childsetting2', 'parentsetting', 'eq', 0);
         
            $ADMIN->add('courses', $temp);

      3. Log in as admin, then navigate to <wwwroot>/admin/settings.php?section=testinghideif
      4. Set the "Parent setting" to "Show children".
      5. You should see two other settings, "Child setting 1" (a filesize input), and "Child setting 2" (a checkbox).
      6. Change the "Parent setting" to "Hide children".
      7. Expected: Both child settings are hidden (the code to hide both used in step 2 is identical).
      8. Actual: Child setting 2 will be hidden, while Child setting 1 will remain visible.

        1. MDL-69748.jpg
          48 kB
          Anna Carissa Sadia

            rezaie9 Shamim Rezaie
            michaelh Michael Hawkins
            Michael Hawkins Michael Hawkins
            Andrew Lyons Andrew Lyons
            Anna Carissa Sadia Anna Carissa Sadia
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

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

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