You are here

function countries_admin_form_submit in Countries 7

Same name and namespace in other branches
  1. 8 countries.admin.inc \countries_admin_form_submit()
  2. 7.2 countries.admin.inc \countries_admin_form_submit()

Process country form submissions.

File

./countries.admin.inc, line 269
Admin page callbacks for the Countries module.

Code

function countries_admin_form_submit($form, &$form_state) {
  $country = (object) $form_state['values'];
  entity_form_submit_build_entity('country', $country, $form, $form_state);

  // Required to trigger an update.
  $iso2 = isset($form['#country']) ? $form['#country']->iso2 : FALSE;
  country_save($country, $iso2);
  if ($iso2) {
    $message = t('The country %country has been updated.', array(
      '%country' => $country->name,
    ));
  }
  else {
    $message = t('Added country %country.', array(
      '%country' => $country->name,
    ));
  }
  drupal_set_message($message);
  $form_state['redirect'] = 'admin/config/regional/countries';
}