[solution] QuickForm_advmultiselect - can you open the form with the SELECTED list already populated from a data set?
| From: | Laurent Laville | Date: | Tue, 30 Aug 2005 12:04:27 +0000 |
| Subject: | [solution] QuickForm_advmultiselect - can you open the form with the SELECTED list already populated from a data set? | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-20666@lists.php.net to get a copy of this message | ||
l Burnerheimerton wrote:
I appreciate your help. Here what I have that is still not working. It's giving the same issue as before - the selected list has one blank entry that you can move to available list. Any help is greatly appreciated! $form = new HTML_QuickForm('amsCustom1'); $form->removeAttribute('name'); // XHTML compliance $all_people = $db->getAssoc("SELECT ..."); $selected_people = $db->getAssoc("SELECT ..."); $form->setDefaults(array( //set form field defaults 'people' => $selected_people) );Nice study case, it will increase my FAQ section. I've reproduced your problem and found orign. your AVAILABLE array is associative array with key => value while your SELECTED array should be only a key list for example, if in your script you have data sets like this: $all_people = array( 'farell' => 'laurent laville', 'mj' => 'martin jansen', 'cellog' => 'greg beaver' ); AND $selected_people = array('farell'); will works fine BUT $selected_people = array('farell' => 'laurent laville'); will produce a such blank line So i suggest to retrieve only the row KEYs from your database for the SELECTED array Hope i'm clear Regards Laurent