Common elements of the language addition and editing form.
$form: A parent form item (or empty array) to add items below.
$language: Language object to edit.
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;
}