Re: HTML_QuickForm_Controller - setDefaultAction behaviour

From: Date: Mon, 29 Sep 2008 09:00:50 +0000
Subject: Re: HTML_QuickForm_Controller - setDefaultAction behaviour
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-29308@lists.php.net to get a copy of this message
Hi, Mario Callisto wrote:
Started with the wizard.php sample at http://pear.php.net/package/HTML_QuickForm_Controller/docs/latest/__filesource/fsource_HTML_QuickForm_Controller__HTML_QuickForm_Controller-1.0.9exampleswizard.php.html and replicated as it is on my test environment. When on page 2 of 3 of the multipage form, after filling with text the text fields and pressing Enter on the keyboard (instead of clicking the Submit button) I am redirected to page 1 and not to page 3 as expected. This should be handled by line 79:
        $this->setDefaultAction('next');
which appears to be ok. The strange abovementioned behaviour should instead be produced by:
        $this->setDefaultAction('back');
Both 'next' and 'back' seem valid names of buttons created a few lines earlier. Substituting it with
        $this->setDefaultAction('doesntexist');
produces the same 'back to page 1' result.
I think this behaviour is unfortunately browser-dependent. Some browsers don't consider any button clicked when one presses "Enter" (and that's when setDefaultAction() works), some consider the first button in the form clicked (and that's the behaviour you are seeing). The only solution is to put the "default" button first, maybe it will also work with tabindex attribute.

« previous php.pear.general (#29308) next »