In my enquiry table I have a field ‘region’, this stores the index value of the region ID.
public function getRegions()
{
return array(
1=>'England',
2=>'Ireland',
3=>'Scotland',
4=>'Wales',
);
}
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);