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

From: Date: Sat, 01 Jun 2002 20:17:51 +0000
Subject: Re: QuickForm installer bug? + Can't display values
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-1561@lists.php.net to get a copy of this message
At 11:53 AM 6/1/2002 +0200, you wrote: ><stirado@campus.gym.itesm.mx> wrote : > >> >> At 10:09 AM 5/31/2002 +0200, you wrote: >>> le 31/05/02 2:21, Sergio Tirado à stirado@campus.gym.itesm.mx a écrit : >>> >>>> Once that was working, I found some problems with one of the two >>>> examples included. I had to comment out a few lines related to >>>> <select> and form validation to get it working. >>> >>> Which example are you talking about ? 1 or 2 ? >> >> Example 1. I had to comment out this lines: >> >> //$select = &$form->getElement('iselTest'); >> //$select->setSize(5); >> //$select->setMultiple(true); > >Check your version of HTML_Common in the HTML directory and update it to the >latest release. QuickForm makes extensive use of this class. You were right. I updated it and now works just fine. >>>> Despite all that, I started playing with it and looks great too, however, >>>> once I made the form I wanted, I can use it to get values from it but >>>> I haven't found a way to get it to display values I have retrieved from >>>> a database. ¿Could someone tell me how to do this? >>> >>> Do you use setDefaults ? Look at the example 1. >> >> Right now I'm doing this and it shows record info the first time only. >> >> require_once("HTML/QuickForm.php"); >> >> if ($_POST["action"]=="Add") { >> $uid = ""; >> } else { >> $p_key = "L00263822"; >> list($uid,$did,$n,$ln) = $u->get($p_key); // Load the record info >> } >> >> $form =& new HTML_QuickForm("$PHP_SELF","POST"); >> $form->addElement('text', 'frm_uid', "User Id", >> "size='9', maxlength='9' >> value='$uid'"); >> $form->addElement('select', 'frm_did', 'Dept:', >> array('Admon'=>'A', >> >> 'Dirección'=>'B','UIB'=>'C','Prepa'=>'D')); >> $form->addElement('text', 'frm_n', 'Name:', >> "size='30', maxlength='30' >> value='$n'"); >> $form->addElement('text', 'frm_ap', 'Last name:', >> "size='30', maxlength='30' >> value='$ln'"); >> $form->addElement('submit', 'action', 'Add'); >> $form->addElement('submit', 'action', 'Remove'); >> $form->display($body); > >This is all wrong. To set the values you have to use either >setDefaults($array of key-value pairs) (when the form is displayed for the >first time) or loadValues() (when the form has errors). The way you declare >your attributes is also wrong. Get rid of the quotes or use an array instead >(example: array('size'=>30, 'maxlength'=>30) or string: 'size=30 >maxlength=30'. Do not set the value of your elements in the attributes (even >if this is possible :-) 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 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. Thank you very much for your time and advice. -- Sergio Tirado

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