/** * Show select country box * * @access public * @param string $name Control name * @param string $value Country code of selected country * @param array $attributes Array of additional select box attributes * @return string */ function select_country_widget($name, $value, $attributes = null) { $country_codes = array_keys(CountryCodes::getAll()); $countries = array(); foreach ($country_codes as $code) { if (Localization::instance()->lang_exists("country {$code}")) { $countries[$code] = lang("country {$code}"); } else { $countries[$code] = CountryCodes::getCountryNameByCode($code); } } // foreach asort($countries); $country_options = array(option_tag(lang('none'), '')); foreach ($countries as $country_code => $country_name) { $option_attributes = $country_code == $value ? array('selected' => true) : null; $country_options[] = option_tag($country_name, $country_code, $option_attributes); } // foreach return select_box($name, $country_options, $attributes); }
/** * Show select country box * * @access public * @param string $name Control name * @param string $value Country code of selected country * @param array $attributes Array of additional select box attributes * @return string */ function select_country_widget($name, $value, $attributes = null) { $country_codes = array_keys(CountryCodes::getAll()); $countries = array(); foreach ($country_codes as $code) { $countries[$code] = lang("country {$code}"); } // foreach asort($countries); $country_options = array(option_tag(lang('none'), '')); foreach ($countries as $country_code => $country_name) { $option_attributes = $country_code == $value ? array('selected' => true) : null; $country_options[] = option_tag($country_name, $country_code, $option_attributes); } // foreach return select_box($name, $country_options, $attributes); }