cyanatide
(Cyanatide)
1
Hi,
I have a list box with multiple choice as follows:
$form->labelEx($model,'site_id');
$form->listBox($model,'site_id', t_site::getAllSiteId(), array('multiple'=>'true', 'size'=>10));
$form->error($model,'site_id');
It work but by default, I have only the last site_id selected. Why just this site? How can I select by default all the site in the list box?
Thanks.
alirz23
(Ali Raza)
2
because you have only one record associated with that record
cyanatide
(Cyanatide)
3
Why? My function getAllSiteId() return a table, so with several records.
And how can I change that?
alirz23
(Ali Raza)
4
I dont understand what exactly you trying to accomplish can you explain
cyanatide
(Cyanatide)
5
I have created a listBox which list my different sites. It works, but when I open a page with this list box, here is the html code that I get:
<select multiple="true" size="10" name="t_site[site_id][]" id="t_site_site_id">
<option value="Site_1">Site_1</option>
<option value="Site_2">Site_2</option>
<option value="Site_3">Site_3</option>
...
<option value="Site_n" selected="selected">Site_n</option>
</select>
As you can see, only Site_n is selected. I would like all option selected when I open my page with this listbox.
broker
(Muratkutluer)
6
It is raleted with site_id attribute. It has to be a relation getting multiple records.
cyanatide
(Cyanatide)
7
Sorry to annoying you, but I don’t understand… Where must be setted this relation? The following lines isn’t enought?
$form->listBox($model,'site_id', t_site::getAllSiteId(), array('multiple'=>'true', 'size'=>10));