You are here

function i18n_path_admin_form_validate in Internationalization 7

Process form validation

File

i18n_path/i18n_path.admin.inc, line 65
Administration pages for path translation.

Code

function i18n_path_admin_form_validate($form, &$form_state) {
  if ($form_state['triggering_element']['#name'] == 'save') {
    $paths =& $form_state['values']['translations'];
    if ($paths = array_filter($paths)) {
      module_load_include('inc', 'menu', 'menu.admin');
      foreach ($paths as $language => &$link_path) {
        $link_path = i18n_prepare_normal_path($link_path, $language);
        $validation_form_state = array(
          'values' => array(
            'link_path' => $link_path,
          ),
        );
        menu_edit_item_validate(array(), $validation_form_state);
      }
    }
    else {
      form_set_error('paths', t('There are no path translations to save.'));
    }
  }
}