form->listBox() id

If we change the id from a $form->listBox(…), the listBox stops working (no validating, ajax call, etc). It’s possible to make the new id, acting like the id that comes from model ?

Changing this




...

$form->listBox($item, 'category_id', CHtml::listData(Category::model()->findAll('parent_id IS NULL'), 'id', 'name'),

...



into this




...

$form->listBox($item, 'category_id', CHtml::listData(Category::model()->findAll('parent_id IS NULL'), 'id', 'name'), array('id'=>'parent'),

...



If what you want is just to be sure of the field’s id, you can use CHtml::activeId() like this


CHtml::activeId($model, 'category_id')

whenever you need the id that was created by Yii

Well, the idea is to change the listBox values, depending on what value you choose from other, but this causes the listbox to stop working. Also you “can’t” have more then 1 form element with the same id, if you want to make something dependent.

Looks like i have to choose other way…

I think I haven’t really understood what you want to achieve.

But is it by any chance dependent dropdowns?

Yes and No :)

Here is what im trying to do

Ok so my suggestion goes in the other thread :)