[QuickForm] select element and exportValue(s) behavior ?

From: Date: Fri, 02 Sep 2005 12:09:52 +0000
Subject: [QuickForm] select element and exportValue(s) behavior ?
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-20740@lists.php.net to get a copy of this message
Hello QF leaders, 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 #5275 regards Laurent <?php require_once('HTML/QuickForm.php'); PEAR::setErrorHandling(PEAR_ERROR_PRINT); // be sure to used good resources $includes = get_included_files(); echo '<pre>'; print_r($includes); echo '</pre>'; // options list $tests = array('', 'test1', 'test2'); $form = new HTML_QuickForm('test'); echo '<pre style="background-color: silver;">'; print_r($_POST); echo '</pre>'; if (isset($_POST['oneSel'])) {
    $form->setDefaults(array('oneSel' => $_POST['oneSel']));
} else {
    $form->setDefaults(array('oneSel' => array(1)));
} $s =& $form->addElement('select', 'oneSel', 'oneSel:', $tests); $s->setMultiple(true); $form->addElement('submit'); //$form->addElement('submit', null, 'Validate'); //$form->addElement('submit', 'send', 'Validate'); echo '<pre style="background-color: lightyellow;">'; var_dump($form->exportValues()); var_dump($form->exportValue('oneSel')); echo '</pre>'; $form->display(); ?>

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