Re: Re: QuickForm_advmultiselect - can you open the form with the SELECTED list already populated from a data set?
| From: | l Burnerheimerton | Date: | Tue, 30 Aug 2005 10:26:12 +0000 |
| Subject: | Re: Re: QuickForm_advmultiselect - can you open the form with the SELECTED list already populated from a data set? | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-20659@lists.php.net to get a copy of this message | ||
--- Laurent Laville <pear@laurent-laville.org> wrote:
> l Burnerheimerton wrote:
> > thanks. based on this, I tried the code below. A
> > blank entry displays in the selected option list -
> you
> > can select it but it has no label/name to it.
>
> Is it a question about a problem you have ? please
> clarify
>
> >
> > print_r() verifies there is an array of values
> getting
> > to both.
> that won't check in the good array
>
> >
> > $form = new HTML_QuickForm('amsCustom1');
> > $form->removeAttribute('name'); // XHTML
> > compliance
> > //get list of services
> > $all_people = $db->getAssoc("SELECT ...");
> > $selected_people = $db->getAssoc("SELECT ...");
> look here
>
> > print_r($all_students);
> > print_r($selected_students);
> and here
>
>
> > $form->setDefaults(array( //set form field
> defaults
> > 'people' => array('people' => $selected_people)
> > )
> > );
>
> but i think you have a problem here with the
> setDefaults method
> you should write
>
> $form->setDefaults(array( //set form field
> defaults
> 'people' => $selected_people)
> );
>
>
> Laurent
>
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)
);
$form->addElement('header', null, 'Advanced Multiple
Select: custom layout ');
$ams =& $form->addElement('advmultiselect', 'people',
null, $all_people,
array('size' => 10,
'class' => 'pool',
'style' => 'width:150px;'
)
);
$ams->setLabel(array('people:', 'Available',
'Selected'));
$ams->setButtonAttributes('add', array('value' =>
'Add >>',
'class' =>
'inputCommand'
));
$ams->setButtonAttributes('remove', array('value' =>
'<< Remove',
'class' =>
'inputCommand'
));
$template = '...';
$ams->setElementTemplate($template);
if (isset($_POST['people'])) {
$form->setDefaults(array('people' =>
$_POST['people']));
}
$form->addElement('submit', 'send', 'Send');
____________________________________________________
Start your day with Yahoo! - make it your home page
http://www.yahoo.com/r/hs