function _language_admin_common_controls

Common elements of the language addition and editing form.

Parameters

$form: A parent form item (or empty array) to add items below.

$language: Language object to edit.

2 calls to _language_admin_common_controls()
language_admin_add_form in drupal/core/modules/language/language.admin.inc
User interface for the language addition screen.
language_admin_edit_form in drupal/core/modules/language/language.admin.inc
Editing screen for a particular language.

File

drupal/core/modules/language/language.admin.inc, line 228
Administration functions for language.module.

Code

function _language_admin_common_controls(&$form, $language = NULL) {
  if (!is_object($language)) {
    $language = new Language(array(
      'langcode' => NULL,
      'name' => NULL,
    ));
  }
  if (isset($language->langcode)) {
    $form['langcode_view'] = array(
      '#type' => 'item',
      '#title' => t('Language code'),
      '#markup' => $language->langcode,
    );
    $form['langcode'] = array(
      '#type' => 'value',
      '#value' => $language->langcode,
    );
  }
  else {
    $form['langcode'] = array(
      '#type' => 'textfield',
      '#title' => t('Language code'),
      '#maxlength' => 12,
      '#required' => TRUE,
      '#default_value' => '',
      '#disabled' => FALSE,
      '#description' => t('Use language codes as <a href="@w3ctags">defined by the W3C</a> for interoperability. <em>Examples: "en", "en-gb" and "zh-hant".</em>', array(
        '@w3ctags' => 'http://www.w3.org/International/articles/language-tags/',
      )),
    );
  }
  $form['name'] = array(
    '#type' => 'textfield',
    '#title' => t('Language name'),
    '#maxlength' => 64,
    '#default_value' => @$language->name,
    '#required' => TRUE,
  );
  $form['direction'] = array(
    '#type' => 'radios',
    '#title' => t('Direction'),
    '#required' => TRUE,
    '#description' => t('Direction that text in this language is presented.'),
    '#default_value' => @$language->direction,
    '#options' => array(
      LANGUAGE_LTR => t('Left to right'),
      LANGUAGE_RTL => t('Right to left'),
    ),
  );
  return $form;
}