You are here

function countries_admin_form in Countries 7.2

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

Generate a country form.

See also

countries_admin_form_validate()

countries_admin_form_submit()

1 string reference to 'countries_admin_form'
countries_admin_page in ./countries.admin.inc
Menu callback; Display a country form.

File

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

Code

function countries_admin_form($form, &$form_state, $country) {
  $form['cid'] = array(
    '#type' => 'value',
    '#value' => $country->cid,
  );
  $form['name'] = array(
    '#type' => 'textfield',
    '#title' => t('Name'),
    '#default_value' => $country->name,
    '#description' => t('Specify an unique name for this country.'),
    '#required' => TRUE,
    '#maxlength' => 95,
  );
  $locked = country_is_locked($country);
  $form['iso2'] = array(
    '#type' => 'textfield',
    '#title' => t('ISO alpha-2 code'),
    '#default_value' => $country->iso2,
    '#required' => TRUE,
    '#maxlength' => 2,
    '#disabled' => $locked,
  );
  if ($locked) {
    $form['iso2']['#description'] = t('Core country ISO alpha-2 codes are not editable.');
  }
  else {
    $form['iso2']['#description'] = t('Specify an unique alpha-2 code for this country. This is used as the key to this country, changing it may result in data loss.');
  }
  $form['iso3'] = array(
    '#type' => 'textfield',
    '#title' => t('ISO alpha-3 code'),
    '#default_value' => $country->iso3,
    '#description' => t('Specify an unique ISO alpha-3 code for this country.'),
    '#required' => FALSE,
    '#maxlength' => 3,
  );
  $form['official_name'] = array(
    '#type' => 'textfield',
    '#title' => t('Official name'),
    '#default_value' => $country->official_name,
    '#description' => t('Specify an unique official name for this country.'),
    '#required' => FALSE,
    '#maxlength' => 127,
  );
  $form['numcode'] = array(
    '#type' => 'textfield',
    '#title' => t('ISO numeric-3 code'),
    '#default_value' => empty($country->numcode) ? '' : $country->numcode,
    '#description' => t('Specify an unique ISO numeric-3 code for this country.'),
    '#required' => FALSE,
    '#maxlength' => 5,
  );
  $form['continent'] = array(
    '#type' => 'select',
    '#title' => t('Continent'),
    '#options' => countries_get_continents(),
    '#default_value' => $country->continent,
    '#required' => TRUE,
  );
  $form['enabled'] = array(
    '#type' => 'checkbox',
    '#title' => t('Status'),
    '#default_value' => $country->enabled,
    '#description' => t('Disabling a country should removing it from all country listings, with the exclusion of views and fields define by the Countries module. These will allow you to choose the status per field.'),
  );
  if (!empty($country->iso2)) {
    $form['#country'] = $country;
  }
  field_attach_form('country', $country, $form, $form_state);
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
    '#weight' => 100,
  );
  return $form;
}