Posted by Leonie on 10/04/23 11:10
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
[Back to original message]
|