Drupal 7 form api - drop-down list countries

Is there a way to have a complete list of countries without creating an array manually

$options = array( '', => 'Please select your country.', 'USA' => 'USA', 'UK' => 'UK', ); 

Is there a way to fill all the countries in the array? Shallow drilling to fill this manually

+4
source share
1 answer

The Drupal core stores a list of all countries / codes prepared manually, so you can transfer them directly to the form element:

 require_once DRUPAL_ROOT . '/includes/locale.inc'; $options = country_get_list(); 
+7
source

All Articles