Re: Quickform - edit form
| From: | Leonie \(phpgroup\) | Date: | Thu, 10 Mar 2005 00:02:03 +0000 |
| Subject: | Re: Quickform - edit form | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-210402@lists.php.net to get a copy of this message | ||
Just as a follow up.
Marek sent me a reply, but for some mysterious reason it didn't appear on the list:
Use either HTML_QuickForm::setDefaults() to set defaults for all elements or HTML_QuickForm_element::setValue() to set value for individual elements. Former is simpler, and if you name the forms elements after the table columns, you can directly pass in array fetched from sql query.I've been able to fill out all the form data as follows, using PEAR DB: //get the form data if it is an edit form if ($_GET['id']) { $sql = 'SELECT * FROM '.TBL_BOOK.' WHERE ID='.$_GET['id']; $res = $db->query($sql); $data = $res->fetchRow(DB_FETCHMODE_ASSOC); $form->setDefaults($data); } As long as the fields are named the same as the table columns, this works well. Thank you to everyone who helped me with this. Leonie