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

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.1.4, 3.2.1, 3.4, 3.5, 3.7.5, 3.8.2, 3.9
    • 3.7.6, 3.8.3
    • Forms Library

    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

              timhunt Tim Hunt
              dasistwas David Bogner
              Mahmoud Kassaei Mahmoud Kassaei
              Andrew Lyons Andrew Lyons
              CiBoT CiBoT
              David Woloszyn, Huong Nguyen, Jake Dallimore, Meirza, Michael Hawkins, Raquel Ortega, Safat Shahin, Stevani Andolo
              Votes:
              14 Vote for this issue
              Watchers:
              21 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                11/May/20

                Time Tracking

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