On 10/8/2012 5:21 PM, Earnie Boyd wrote:
On Mon, Oct 8, 2012 at 3:45 PM, Pat Newberry wrote:
After some Google searching I found I could add to a function Hook to an existing custom module that deals with forms (written by 3rd party) with a hook for countries alter.
function myCustomMod_countries_alter(&$countries) {
$countries['IE'] = 'Republic of Ireland-xx'; $countries['GB'] = 'Great Britain'; $countries['RU'] = 'Russian Federation'; $countries['CI'] = 'Cote d' lvoire'; $countries['BA'] = 'Bosnia Herzegovina'; $countries['NN'] = 'Northern Ireland';
}
Now when I go to the view, this has no effect on the list of countries, but when I go to the search page that uses this view with exposed criteria and form, I can see that the countries that exist in the iso file (e.g. Republic of Ireland with an -xx) are modified with my changes from the countries_alter hook, but the countries that do not exist in the iso file are not added (e.g. Northern Ireland). I am guessing at the time the exposed search drop down list is built, it has my changes in it (altered and added) but that it checks against the values that are checked in the view and if it's not check in the view, it won't get added to the list.
Have you cleared the caches? admin/config/development/performance
So looking for advice as to what direction I should head.
1.) Hack the ISO.inc file. 2.) learn how to attach another .inc file to the field_address:country 3.) another hook or code in the hook alter that will work when the form is rendered.
Perhaps another hook. Have you looked at drupal.org/project/location? Do you know about api.drupal.org?
Using the information in this link (http://drupal.stackexchange.com/questions/4559/how-to-alter-country-dropdown...) I was able to accomplish what I needed done. I had an existing custom module in which I added this code:
/** * Implements hook_form_alter(). */ function MyModule_form_alter(&$form, &$form_state, $form_id) { if ($form['#id'] == 'views-exposed-form-listing-search-page') { $form['#after_build'][] = 'custom_countries_after_build'; } }
/** * Make changes to countries field after all fields are rendered */ function custom_countries_after_build($form_element, &$form_state) { $form_element['country']['#options']['NN'] = 'Northern Ireland'; $form_element['country']['#options']['IE'] = 'Republic of Ireland'; $form_element['country']['#options']['GB'] = 'Great Britain'; $form_element['country']['#options']['RU'] = 'Russian Federation'; $form_element['country']['#options']['CI'] = 'Cote d' lvoire'; $form_element['country']['#options']['BA'] = 'Bosnia Herzegovina'; $form_element['country']['#options']['CD'] = 'Democratic Republic of Congo';
asort($form_element['country']['#options']);
return $form_element; }