I create a component file Country inside components folder. It have a function that returns country list from API. I am using this function for drop downlist in a form. The country listed correctly in drop list, but on saving time the corresponding id of country is saved in db. How it solve? I want to save the country name.
$data is array of (value=>display), so probably your function passing it like id=>country_name, You should change this getCountry() method to set array like (country_name=>country_name)
And i think that new model is not needed here at all.
Yes. But not working. listData() need two parameters. Also tried this CHtml::listData(Country::getCountry(),’ ', ’ ') , but it doesn’t load the country list.