Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 3.2.16

Bug #18530 Autocomplete broken on Firefox 4
Submitted: 2011-05-12 20:29 UTC
From: ednawig Assigned: avb
Status: Closed Package: HTML_QuickForm (version 3.2.12)
PHP Version: 5.2.10 OS: linux
Roadmaps: (Not assigned)    
Subscription  


 [2011-05-12 20:29 UTC] ednawig (Edna Wigderson)
Description: ------------ Autocomplete does not work on FF4. The console reports "autocomplete is not a function" Test script: --------------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head></head> <body> <h3>Autocomplete</h3> <?php $fruits = array("Bananas","Grapes","Oranges"); require_once 'HTML/QuickForm.php'; $form = new HTML_QuickForm(); // add auto-complete input field $ac0 = $form->addElement('autocomplete', 'fruit','Fruit:',$fruits); $form->addElement('submit', null, 'Submit'); // print submitted values // render and display the form if ($form->validate()) { $form->freeze(); print_r($_POST); } else { $form->display(); } ?> </body> </html> Expected result: ---------------- Expected: type the letter 'b' in the box, and it should complete to 'Bananas'. This is what I get on FF3 and other browsers (chrome, safari, IE) Actual result: -------------- FF4 does not complete and the Web Developer console displays an "autocomplete is not a function" error

Comments

 [2011-05-12 21:47 UTC] avb (Alexey Borzov)
-Status: Open +Status: Analyzed
Probably conflicts with autocomplete attribute of HTML5: http://www.whatwg.org/specs/web-apps/current-work/multipage/common-input-element-attributes.html#the-autocomplete-attribute Dunno why js functions of the element were not namespaced / prefixed.
 [2011-06-16 21:48 UTC] shadesofgraylin (Graylin Kim)
I tried submitting via `Add patch` repeatedly but never received a confirmation email. Since the patch is simple enough, I'm trying again here. You can patch this issue by scoping the autocomplete function to the window with the following patch. Index: QuickForm/autocomplete.php =================================================================== --- QuickForm/autocomplete.php (revision 312209) +++ QuickForm/autocomplete.php (working copy) @@ -124,7 +124,7 @@ $arrayName = str_replace(array('[', ']'), array('__', ''), $this->getName()) . '_values'; $this->updateAttributes(array( - 'onkeypress' => 'return autocomplete(this, event, ' . $arrayName . ');' + 'onkeypress' => 'return window.autocomplete(this, event, ' . $arrayName . ');' )); if ($this->_flagFrozen) { $js = '';
 [2011-10-01 13:55 UTC] avb (Alexey Borzov)
-Status: Analyzed +Status: Closed -Assigned To: +Assigned To: avb
This bug has been fixed in SVN. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.