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

single select autocomplete elements should not allow clearing

    XMLWordPrintable

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 3.7.8, 3.8.5, 3.9.2, 3.10
    • None
    • Forms Library
    • None
    • MOODLE_310_STABLE, MOODLE_37_STABLE, MOODLE_38_STABLE, MOODLE_39_STABLE
    • Hide

      I am pretty sure it works if you set this form field to be a requried field. That prevents the form being submitted with a blank value.

      Show
      I am pretty sure it works if you set this form field to be a requried field. That prevents the form being submitted with a blank value.

    Description

      Just like a normal select element, in autocompliete elements, a user should only be able to select an item from what is provided in the list of options. If "" (an empty string) is not within the options, then when the form first loads, the choice should not be blank, and the user should not be able to de-select the current value.

      Before MDL-57680, users could sometimes clear the current value, and sometimes could not, depending on what previous actions they had take. That issue made the behaviour consistent, but probably in the wrong way.

      This is just an example of how to reproduce the bug, but it can be replicated on many other pages as well:

      1. log in as admin
      2. Go to Site administration > Courses > Manage courses and categories
      3. Click on the "Create new course" button
      4. Type something in the "Course full name" and "Course short name" fields
      5. Clear the "Course category" field
      6. Submit the form

      You'll see the following error:

      Can't find data record in database table course_categories.More information about this error
       
      Debug info: SELECT * FROM {course_categories} WHERE id IS NULL
      [array (
      )]
      Error code: invalidrecord
       
      Stack trace:
      * line 1646 of /lib/dml/moodle_database.php: dml_missing_record_exception thrown
      * line 1622 of /lib/dml/moodle_database.php: call to moodle_database->get_record_select()
      * line 2322 of /course/lib.php: call to moodle_database->get_record()
      * line 162 of /course/edit.php: call to create_course()
       
      Output buffer: <br /> <b>Notice</b>: Undefined property: stdClass::$category in <b>/opt/app/course/lib.php</b> on line <b>2322</b><br />

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              rezaie9 Shamim Rezaie
              David Woloszyn, Huong Nguyen, Jake Dallimore, Meirza, Michael Hawkins, Raquel Ortega, Safat Shahin, Stevani Andolo
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated: