Hi I have a dynamic dropdown list and my code is
$myArray=CHtml::listData(brand::model()->findAll(), ‘id’, ‘brandname’);
but I want that their is also an option or the default in dropdown is null, i dnt know how?
Hi I have a dynamic dropdown list and my code is
$myArray=CHtml::listData(brand::model()->findAll(), ‘id’, ‘brandname’);
but I want that their is also an option or the default in dropdown is null, i dnt know how?
You could use special properties ‘prompt’ and ‘empty’ for your dropdownlist control - see http://www.yiiframework.com/doc/api/1.1/CHtml#dropDownList-detail.
Also, instead of this, you could write code like this:
$myArray = CHtml::listData(brand::model()->findAll(), 'id', 'brandname') + array('' => 'Empty text');