1.20.x language.admin.inc | language_admin_edit_form_validate($form, &$form_state) |
Validate the language editing form. Reused for custom language addition too.
File
- modules/
language/ language.admin.inc, line 309 - Admin page callbacks for the Language module.
Code
function language_admin_edit_form_validate($form, &$form_state) {
// Ensure sane field values for langcode and name.
if (!isset($form['langcode_view']) && preg_match('@[^a-zA-Z_-]@', $form_state['values']['langcode'])) {
form_set_error('langcode', t('%field may only contain characters a-z, underscores, or hyphens.', array('%field' => $form['langcode']['#title'])));
}
if ($form_state['values']['name'] != check_plain($form_state['values']['name'])) {
form_set_error('name', t('%field cannot contain any markup.', array('%field' => $form['name']['#title'])));
}
if ($form_state['values']['native'] != check_plain($form_state['values']['native'])) {
form_set_error('native', t('%field cannot contain any markup.', array('%field' => $form['native']['#title'])));
}
}