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

Autocomplete form field element causes javascript error on keypress

    XMLWordPrintable

Details

    • Bug
    • Resolution: Deferred
    • Minor
    • None
    • 2.2.1
    • Forms Library
    • None
    • MOODLE_22_STABLE
    • Hide

      Edit any form in the system (I used forgot_password form to test with) and add these lines

      $autocomplete =$mform->addElement('autocomplete', 'fruit', 'Favourite fruit:');
      $options = array("Apple", "Orange", "Pear", "Strawberry");
      $autocomplete->setOptions($options);

      Visit the form's web page, put the cursor in the Favourite fruit box and start typing - watch the javascript console for errors.

      Show
      Edit any form in the system (I used forgot_password form to test with) and add these lines $autocomplete =$mform->addElement('autocomplete', 'fruit', 'Favourite fruit:'); $options = array("Apple", "Orange", "Pear", "Strawberry"); $autocomplete->setOptions($options); Visit the form's web page, put the cursor in the Favourite fruit box and start typing - watch the javascript console for errors.

    Description

      If you create an autocomplete form field element and try to use it, the javascript error "autocomplete is not a function" occurs on keypress in the text box. The function clearly exists in the html source for the page though.

      This specific form field hasn't changed between Moodle 1.9 and Moodle 2.0, but the autocomplete feature did work in Moodle 1.9, so I'm not sure why its broken now. Oddly, if you change the function name to "autocompl" it works perfectly. That made me think there must be some other autocomplete() javascript function somewhere causing a conflict, but I searched the codebase and can't find one!

      We've seen this in a range of browsers including IE8, FF10 and chrome.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              jenny-gray Jenny Gray
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Clockify

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