zii.widgets.CListView drops htmlOptions['id']

Hi, I’ve found this in CBaseListView:


which I think it’s a bug, because if I need to set a specific ID for a CGridView or CListView, I can’t. So I made this patch:

Index: lib/yii-1.1.8.r3324/framework/zii/widgets/CBaseListView.php


--- yii-1.1.8.r3324/framework/zii/widgets/CBaseListView.php (revisión: 326)

+++ yii-1.1.8.r3324/framework/zii/widgets/CBaseListView.php (copia de trabajo)

@@ -104,7 +104,7 @@




-           	$this->htmlOptions['id']=$this->getId();

+           	if (!isset($this->htmlOptions['id'])) $this->htmlOptions['id']=$this->getId();


            	if($this->enableSorting && $this->dataProvider->getSort()===false)


I hope this patch doesn’t break other things.

But there is a property named ‘id’ for every widget. CWidget::id

I’m not sure, but I’m afraid that this may cause an inconsistency between the widget’s ID and the jquery scripts that refer to the widget by its ID.

Ok, I missed the $list = $this->widget(‘CListView’ …); then $id = $list->getId(). Patch reverted :)