Listbox: Select All By Default

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.

because you have only one record associated with that record

Why? My function getAllSiteId() return a table, so with several records.

And how can I change that?

I dont understand what exactly you trying to accomplish can you explain

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.

It is raleted with site_id attribute. It has to be a relation getting multiple records.

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));