1 language.admin.inc | language_admin_add_form($form, &$form_state) |
User interface for the language addition screen.
File
- core/
modules/ language/ language.admin.inc, line 120 - Admin page callbacks for the Language module.
Code
function language_admin_add_form($form, &$form_state) {
$predefined_languages = language_admin_predefined_list();
$predefined_languages['custom'] = t('Custom language...');
$predefined_default = !empty($form_state['values']['predefined_langcode']) ? $form_state['values']['predefined_langcode'] : key($predefined_languages);
$form['predefined_langcode'] = array(
'#type' => 'select',
'#title' => t('Language name'),
'#default_value' => $predefined_default,
'#options' => $predefined_languages,
);
$form['predefined_submit'] = array(
'#type' => 'submit',
'#value' => t('Add language'),
'#limit_validation_errors' => array(array('predefined_langcode'), array('predefined_submit')),
'#states' => array(
'invisible' => array(
'select#edit-predefined-langcode' => array('value' => 'custom'),
),
),
'#validate' => array('language_admin_add_predefined_form_validate'),
'#submit' => array('language_admin_add_predefined_form_submit'),
);
$form['custom_language'] = array(
'#type' => 'container',
'#states' => array(
'visible' => array(
'select#edit-predefined-langcode' => array('value' => 'custom'),
),
),
);
_language_admin_common_controls($form['custom_language']);
$form['custom_language']['submit'] = array(
'#type' => 'submit',
'#value' => t('Add custom language'),
'#validate' => array('language_admin_add_custom_form_validate'),
'#submit' => array('language_admin_add_custom_form_submit'),
);
return $form;
}