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

Forms hideIf/disabledIf 'in' rule not correctly implemented for multiselect/autocomplete

    • MOODLE_405_STABLE, MOODLE_500_STABLE, MOODLE_501_STABLE
    • MDL-85514-main
    • Hide
      1. Place the test form 'testform.php' (attached to this issue), at your webroot
      2. Go to SITE/testform.php. There, you'll see an autocomplete (supporting selection of multiple options). The option that should trigger the hideIf is "Third placement type".
      3. Try different combinations of selected items and verify the form only shows the hidden text field when "Third placement type" is in the selection (also test the "no selection" case).
      Show
      Place the test form 'testform.php' (attached to this issue), at your webroot Go to SITE/testform.php. There, you'll see an autocomplete (supporting selection of multiple options). The option that should trigger the hideIf is "Third placement type". Try different combinations of selected items and verify the form only shows the hidden text field when "Third placement type" is in the selection (also test the "no selection" case).
    • Hide

      Code verified against automated checks with warnings.

      Checked MDL-85514 using repository: https://github.com/snake/moodle

      Should these errors be fixed?

      Built on: Tue May 27 02:59:56 UTC 2025

      Show
      Code verified against automated checks with warnings. Checked MDL-85514 using repository: https://github.com/snake/moodle main (0 errors / 1 warnings) [branch: MDL-85514-main | CI Job ] overview (0/1) , phplint (0/0) , phpcs (0/0) , js (0/0) , css (0/0) , phpdoc (0/0) , commit (0/0) , savepoint (0/0) , thirdparty (0/0) , externalbackup (0/0) , grunt (0/0) , shifter (0/0) , mustache (0/0) , gherkin (0/0) , Warn: The MDL-85514 -main branch at https://github.com/snake/moodle has not been rebased recently (>20 days ago). Should these errors be fixed? Built on: Tue May 27 02:59:56 UTC 2025
    • 3
    • Team Alpha - Sprint 1 I2-2025, Team Alpha - Sprint 2 I2-2025

      Originally reported at the end of the description in MDL-83563, but was not addressed in that issue. Discovered during tech. discovery on MDL-85358.

      Note: The 'in'-comparison currently behaves just like the 'eq'-comparison for multi-selects (i.e., the list of selected values must match the given list of values exactly). I would argue that it would make more sense to do the comparison separately for each selected element (i.e., each selected value must appear in the given list of values). This would mean that the 'in'-comparison succeeds if and only if the set of selected values is a subset of the given set of values. Otherwise, the 'in'-comparison doesn't serve any purpose in this situation.

      Currently, if you want to set up the multiselect/autocomplete such that the inclusion of an option in the selected options (i.e. it's one of potentially many selected options) controls another form element with hideIf/disabledIf, you end up needing a multitude of hideIf rule declarations, covering all possible combinations of options, since it's implemented the same as 'eq'. This rapidly grows out of control.

      This is a problem and it should be fixed. It's neither intuitive, nor correct for the multiselects/autocompletes, where it should be checking whether the selection is a subset of the rule values.

      See also my comment here: https://tracker.moodle.org/browse/MDL-85358?focusedId=1158607&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-1158607, which provides a branch with a demo form, highlighting the problem.

      This currently blocks MDL-85359 in the LTI project.

      Note: this will also impact admin settings which also uses a similar hideif rule for admin settings, which currently also behaves like 'eq'.

            jaked Jake Dallimore
            jaked Jake Dallimore
            Votes:
            2 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 3 hours
                3h

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