You are here

function entity_translation_entity_form_language_update in Entity Translation 7

Validation handler for the entity language widget.

1 string reference to 'entity_translation_entity_form_language_update'
EntityTranslationDefaultHandler::entityFormLanguageWidget in includes/translation.handler.inc

File

./entity_translation.module, line 1578

Code

function entity_translation_entity_form_language_update($element, &$form_state, $form) {
  $handler = entity_translation_entity_form_get_handler($form, $form_state);

  // Ensure the handler form language match the actual one. This is mainly
  // needed when responding to an AJAX request where the languages cannot be set
  // from the usual page callback.
  if (!empty($form_state['entity_translation']['form_langcode'])) {
    $handler
      ->setActiveLanguage($form_state['entity_translation']['form_langcode']);
  }

  // When responding to an AJAX request we should ignore any change in the
  // language widget as it may alter the field language expected by the AJAX
  // callback.
  if (empty($form_state['triggering_element']['#ajax'])) {
    $handler
      ->entityFormLanguageWidgetSubmit($form, $form_state);
  }
}