I am new to Yii and frankly new to Object oriented php also. I am trying to learn this. Just needed some help.
I am using the yii-user extension and I can add profile fields using that. I need a add a profile field to create a drop-down list of countries or states.
I think i need to create a widget for that, since I’m new, I don’t know what to do ??
There’s an easy way to do this. Create a profile field called whatever you like and in the Range box, put a list of country separated by semi-colons. It will automatically be converted to a drop down list. Mine looks like this:
United Kingdom;Australia;Canada;New Zealand;United States;Afghanistan;Albania;Algeria;Andorra;Angola;Antigua & Deps;Argentina;Armenia;Austria;Azerbaijan;Bahamas;Bahrain;Bangladesh;Barbados;Belarus;Belgium;Belize;Benin;Bhutan;Bolivia;Bosnia Herzegovina;Botswana;Brazil;Brunei;Bulgaria;Burkina;Burundi;Cambodia;Cameroon;Cape Verde;Central African Rep;Chad;Chile;China;Colombia;Comoros;Congo;Congo {Democratic Rep};Costa Rica;Croatia;Cuba;Cyprus;Czech Republic;Denmark;Djibouti;Dominica;Dominican Republic;East Timor;Ecuador;Egypt;El Salvador;Equatorial Guinea;Eritrea;Estonia;Ethiopia;Fiji;Finland;France;Gabon;Gambia;Georgia;Germany;Ghana;Greece;Grenada;Guatemala;Guinea;Guinea-Bissau;Guyana;Haiti;Honduras;Hungary;Iceland;India;Indonesia;Iran;Iraq;Ireland {Republic};Israel;Italy;Ivory Coast;Jamaica;Japan;Jordan;Kazakhstan;Kenya;Kiribati;Korea North;Korea South;Kosovo;Kuwait;Kyrgyzstan;Laos;Latvia;Lebanon;Lesotho;Liberia;Libya;Liechtenstein;Lithuania;Luxembourg;Macedonia;Madagascar;Malawi;Malaysia;Maldives;Mali;Malta;Marshall Islands;Mauritania;Mauritius;Mexico;Micronesia;Moldova;Monaco;Mongolia;Montenegro;Morocco;Mozambique;Myanmar, {Burma};Namibia;Nauru;Nepal;Netherlands;Nicaragua;Niger;Nigeria;Norway;Oman;Pakistan;Palau;Panama;Papua New Guinea;Paraguay;Peru;Philippines;Poland;Portugal;Qatar;Romania;Russian Federation;Rwanda;St Kitts & Nevis;St Lucia;Saint Vincent & the Grenadines;Samoa;San Marino;Sao Tome & Principe;Saudi Arabia;Senegal;Serbia;Seychelles;Sierra Leone;Singapore;Slovakia;Slovenia;Solomon Islands;Somalia;South Africa;Spain;Sri Lanka;Sudan;Suriname;Swaziland;Sweden;Switzerland;Syria;Taiwan;Tajikistan;Tanzania;Thailand;Togo;Tonga;Trinidad & Tobago;Tunisia;Turkey;Turkmenistan;Tuvalu;Uganda;Ukraine;United Arab Emirates;Uruguay;Uzbekistan;Vanuatu;Vatican City;Venezuela;Vietnam;Yemen;Zambia;Zimbabwe
I prioritised the countries most likely to be useful to us. I got the data here[1] and used gedit to replace newlines with semi-colons. Easy as pie.
[1] I’m a new user so I can’t post links, add http to the front of this for the list: openconcept.ca/blog/mgifford/text_list_all_countries
Update: Ok, turns out the range value is limited to 255 characters. There is a simple solution for that, simply modify the tbl_profile_fields table, change the row range from a VARCHAR(255) to a TEXT. You can do this in phpMyAdmin or on the command line through mysql with a query like:
ALTER TABLE `tbl_profiles_fields` CHANGE `range` `range` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL
Thanks for your response here. My question is, how will it be automatically converted to a drop down list? How can I use the list of countries saved in the table as a drop down list in my view files?