Re: setting values in select element
| From: | Ashley Etchell | Date: | Mon, 09 Jan 2006 20:32:26 +0000 |
| Subject: | Re: setting values in select element | ||
| References: | 1 2 3 4 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-22479@lists.php.net to get a copy of this message | ||
this example may clarify:
$form = new HTML_QuickForm('company', 'POST',_SELF,'','company');
$prh = $db->prepare('SELECT company,id FROM central order by company asc');
$res = $db->execute($prh);
if($res->numRows() > 0) {
$select['NONE'] = 'Select a company';
// create select values
while($row = $res->fetchRow()) {
$select[$row['id']] = $row['company'];
}
}
if($form->validate()) {
$defaults = array('cid' => $_REQUEST['cid']);
$form->setDefaults($defaults);
$client_limit = ' WHERE cid = '.$_REQUEST['cid'];
}
// create selevt and add values from db
$sel = &$form->addElement('select', 'cid', '', $select);
$form->addElement('submit','submit','select');
$renderer =& new HTML_QuickForm_Renderer_ArraySmarty($tpl);
$form->accept($renderer);
$form = $renderer->toArray();
regards
ash
----- Original Message ----- From: "Justin Patrin" <papercrane@gmail.com>
To: "Damien Cros" <damienc@cc.in2p3.fr>
Cc: "PEAR general list" <pear-general@lists.php.net>
Sent: Monday, January 09, 2006 5:22 PM
Subject: Re: [PEAR] setting values in select element
On 1/9/06, Damien Cros <damienc@cc.in2p3.fr> wrote:
Hi, My form has a select element used to build a SQL query. My problem is: quickform gives number to the values of the options,QuickForm does nothing of the sort. The values of select options are entirely up to you. Look further into how you're setting the options. -- Justin Patrin -- PEAR General Mailing List (http://pear.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php