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

Autocomplete form field element causes javascript error on keypress

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.2.1
    • Fix Version/s: None
    • Component/s: Forms Library
    • Labels:
      None
    • Testing Instructions:
      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.
    • Affected Branches:
      MOODLE_22_STABLE

      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.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Votes:
                  0 Vote for this issue
                  Watchers:
                  2 Start watching this issue

                  Dates

                  • Created:
                    Updated: