[solved] activeDropDownList default selected value

In my enquiry table I have a field ‘region’, this stores the index value of the region ID.

public function getRegions()


	return array(







public function getEnquiryRegion()


	return $this->Regions[$this->region];


I now wish to populate a dropDownList for attribute ‘supplier_region’, which is defined as public $supplier_region (does not exist in the database).

Using normal dropDownList method I can do:

echo CHtml::dropDownList('supplier_region', $model->EnquiryRegion, $model->Regions);

And that will auto-select the correct region. But how can I do this using activeDropDownList?

echo CHtml::activeDropDownList($model, 'supplier_region', $model->Regions);

need to set value before;

$model->region = 2;

$model->region = $model->EnquiryRegion;

echo CHtml::activeDropDownList($model, 'region', $model->Regions);

I was just going to put this out there for anyone who wants to set a default selected value on new records only:

Here’s what I’ve come up with:

	<?php $model->isNewRecord ? $model->address_country = 'US' : ''; // default ?>

	<div class="row">

		<?php echo $form->labelEx($model,'address_country'); ?>

		<?php echo $form->dropDownList($model,'address_country',$model->getCountriesList()); ?>

		<?php echo $form->error($model,'address_country'); ?>


Hope it helps someone :)