Limiting Values in a dropDownList

I have a the following table Location.(LocationId, RegionCode, RegionName, Active).

I would like to take the dropDownList below and limit the output to only display those RegionName’s that have Active set to ‘Y’


echo GxHtml::dropDownList('RegionCode','', GxHtml::listDataEx(Location::model()->findAll(),'RegionCode', 'RegionName'),

Can someone help me get the desired result?

Hi you can try the following steps .

step : 1 => do this code in model


public function activeRegion()

	{	

		$WHERE_PART = 'Active="Y"';

		$data = Yii::app()->db->createCommand()

			->select('RegionName')

			->from('Location')

			->where($WHERE_PART)

			->queryAll();

		return $data;

	}

step : 2 => do this code in view file


<?php echo CHtml::activeDropDownList($model,'Element_name', $model->activeRegion(),array('prompt'=>'Select')); ?>

Thanks for the help Kiran Sharma. This is what I want. I just switched to queryColumn() to remove the numbering in the dropdown caused by queryAll()