Re: QuickForm installer bug? + Can't display values

From: Date: Sun, 02 Jun 2002 01:02:50 +0000
Subject: Re: QuickForm installer bug? + Can't display values
References: 1 2  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-1567@lists.php.net to get a copy of this message
Sergio Tirado wrote: >Now setDefaults is working but it doesn't help me to achive the intended >result. I looked for a loadValues method but couldn't find it anywhere. I tried >'cat QuickForm.php | grep -i loadvalue' and found nothing there or on any >of the files under the QuickForms directory. I'm lost here, I don't know how >to use loadValues(). > >I placed an example of what I'm trying to do here: > >http://www.gym.itesm.mx/QuickForm/quickform.php > >I believe this will clearly explain what I'm trying to do. > >This is the code: > >http://www.gym.itesm.mx/QuickForm/code.txt Posted values (empty) are overriding your default values. Try like this: if ($_POST["action"]=="Add") { $defaultValues['frm_uid'] = ""; $defaultValues['frm_did'] = ""; $defaultValues['frm_n'] = ""; $defaultValues['frm_ap'] = ""; $defaultValues['frm_am'] = ""; $form->setConstants($defaultValues); // notice this... } elseif ($_POST["action"]=="Edit") { $p_key = "L00263822"; list($uid,$did,$n,$ap,$am) = $u->get($p_key); $defaultValues['frm_uid'] = "$uid"; $defaultValues['frm_did'] = "$did"; $defaultValues['frm_n'] = "$n"; $defaultValues['frm_ap'] = "$ap"; $defaultValues['frm_am'] = "$am"; $form->setConstants($defaultValues); // ...and this } You should also remember to validate form before this code, not after. >If you press the Add end Edit buttons you'll see a mesage explaining the >intended result. Also, I'm wondering how to tell QuickForm to use a >enctype="multipart/form-data" attribute. $form->updateAttributes(array('enctype' => "multipart/form-data")); - Wojtek

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