QuickForm quirck or user error?

From: Date: Tue, 25 Mar 2003 09:29:00 +0000
Subject: QuickForm quirck or user error?
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-4410@lists.php.net to get a copy of this message
Hi, Since I want to code a wizard-like form I need to take care myself of some (hidden) form variables. What I want is to let the user enter data in the form and after submission he should see the same form in frozen mode. Then, still he should be able to return to (unfrozen) edit mode if necessary. Also I want to inform the user which fields he actually changed. That is why I also need the default values the form started with right from the beginning as hidden values. Unfortunately I bumped into an unexpected problem with the saved hidden date variable! The following code shows it. The date is saved in the default setting $dV['Date'] as an array, then saved as a copy in $dV['oDate']. The hidden element gets added and still var_dumps show that everything is okay, meaning oDate being shown as an array. BUT, after form submission and form validation $form->process() prints out only a "string(0)" as the content of 'oDate' whereas 'Date' is fine. What's going on here? Any clue? Marko ---snip--- <?php include_once('HTML/QuickForm.php'); $form = new HTML_QuickForm('Test', 'post'); // form vars: $dV['Date'] = array('d'=>11, 'm'=>1, 'Y'=>2003); // save initial values foreach($dV as $key => $value) $odV['o'.$key] = $value; echo '<PRE>'; var_dump($odV); // append initial values and add hidden elements for them foreach($odV as $key => $value) { $dV[$key] = $value; $form->addElement('hidden', $key,$value); } var_dump($dV); echo '<PRE>'; $form->setDefaults($dV); $form->addElement('date', 'Date', 'Date:', array('format'=>'d.m.Y', 'minYear'=>1999, 'maxYear'=>2005 )); $form->addElement('submit', 'post', 'set'); if ($form->validate()) { $form->freeze(); $form->process(); } $form->display(); ?> /* Output of script after submission: array(1) { ["oDate"]=> array(3) { ["d"]=> int(11) ["m"]=> int(1) ["Y"]=> int(2003) } } array(2) { ["Date"]=> array(3) { ["d"]=> int(11) ["m"]=> int(1) ["Y"]=> int(2003) } ["oDate"]=> array(3) { ["d"]=> int(11) ["m"]=> int(1) ["Y"]=> int(2003) } } array(3) { ["oDate"]=> string(0) "" <<<--- WATCH THIS!!! ["Date"]=> array(3) { ["d"]=> string(2) "11" ["m"]=> string(1) "1" ["Y"]=> string(4) "2003" } ["post"]=> string(3) "set" } array(0) { } */ ?> ---snip---

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