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

Autocomplete Form API: Can't clear single-select value, and does not fire change event

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.1.4, 3.2.1, 3.4, 3.5, 3.7.5, 3.8.2, 3.9
    • Fix Version/s: 3.7.6, 3.8.3
    • Component/s: Forms Library
    • Labels:

      Description

      The autocomplete Form API has the following problems:

      1. Adding options $options = array('multiple' => false); will render a multi-select autocomplete-form not a single-select. Workaround: Do not add the array key 'multiple' at all, then autocomplete will stay a single choice field.
      2. $mform->disabledIf does not work with autocomplete
      3. Given $options = array('tags' => true); will render a single choice autocomplete form, but once a value is selected, it can not be removed anymore. It can only be replaced by another value. That should only happen when the field is set to "required". So even, if this field is not required, it is somehow difficult to leave it blank, once a value is selected. See MDL-63125
      4. Saving blank autocomplete formfields, will result in multiple problem processing the form data. So there is a dirty hack to process an empty form. The items have to contain this value: qf_force_multiselect_submission, it has to be filtered after form submission. For an example have a look at this commit: [https://github.com/dasistwas/moodle-mod_datalynx/commit/d09a2cd2279e1d97aa6bc2c2453e4da39efa3f76 - see MDL-64151

      Before start any work here, please read my comment below, if might be the case, please split the fix into small issues to limit the scope.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              timhunt Tim Hunt
              Reporter:
              dasistwas David Bogner
              Peer reviewer:
              Mahmoud Kassaei
              Integrator:
              Andrew Nicols
              Tester:
              CiBoT
              Participants:
              Component watchers:
              Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias
              Votes:
              14 Vote for this issue
              Watchers:
              20 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                11/May/20

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 15 minutes
                  15m