Re: Quickform - edit form

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux