Re: [QuickForm] select element and exportValue(s) behavior ?
| From: | Alexey Borzov | Date: | Fri, 02 Sep 2005 14:13:07 +0000 |
| Subject: | Re: [QuickForm] select element and exportValue(s) behavior ? | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-20750@lists.php.net to get a copy of this message | ||
Hi,
Laurent Laville wrote:
I've analysed today bug #5275 (http://pear.php.net/bugs/bug.php?id=5275) declared for HTML_QuickForm_advmultiselect (QFAMS) package. I think it's not a QFAMS bug, but a QF/select element behavior. I don't know if it's really as expect or if it's a QF bug ! So i prefer to ask for confirmation. For information my config is : - Windows XP SP2 - PEAR 1.3.6 - HTML_Common 1.2.1 - HTML_QuickForm 3.2.5 (i've also tested it with 3.2.4pl1 => same behavior) - PHP 4.3.10 Here is the script to demonstrate the problem. - silver color area gave $_POST (submitted values) - lightyellow color area gave exportValues() 1. At first run , multiple select box has option 'test1' set as expected by the setDefaults() method. 2 Unselect the test1 option (CTRL click) and submit the form 3. $_POST is empty and script re-apply the setDefaults() method with default value (key-code 1 stand for 'test1') it's impossible to have then an empty select box in this condition. But rather then wrote $form->addElement('submit'); or even $form->addElement('submit', null, 'Validate'); test it with $form->addElement('submit', 'send', 'Validate'); then an element (submit button) is into submitted array and the script work as expected At 2nd loop, after unselected 'test1' option the select box is without any selection. Hope my explains are enough clear to demonstrate the problem and my question and position against bug #5275. Waiting for a reply, before taking action to bug #5275The problem is the following: if the form contains only a multiple select element, then there is no way to distinguish between two cases: 1) form wasn't yet submitted or 2) form was submitted but with all options unselected. In either case the submitted values array ($_POST or $_GET) is empty. Therefore if you need proper behaviour, you'll need to have something that's guaranteed to be within submit values, there is a $trackSubmit parameter for QuickForm's constructor designed for exactly that. There is also a bug introduced in 3.2.5 where the behaviour of single select is too similar to that of multiple. I'm going to fix that and release 3.2.5pl1 soon. But the ultimate answer is to *not* have a form where it is impossible to know whether it was submitted or not and therefore use $trackSubmit.