Dropdown Country List with Code Igniter and Zend Framework

Note: This assumes you are using Code Igniter, have loaded the form helper, and have followed this guide to integrating Zend Framework with CodeIgniter.

This was so easy that it was scary!

public function country_list($field_name="country",$selected="US")
$locale = new Zend_Locale('en_US');
$countries = ($locale->getTranslationList('Territory','en',2));

return form_dropdown($field_name,$countries,$selected);

This returns a nice list of countries with the 2-letter codes as the option values.

Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: