public function EntityTranslationDefaultHandler::entityFormLanguageWidgetSubmit in Entity Translation 7
Overrides EntityTranslationHandlerInterface::entityFormLanguageWidgetSubmit
See also
EntityTranslationHandlerInterface::entityFormLanguageWidgetSubmit()
2 methods override EntityTranslationDefaultHandler::entityFormLanguageWidgetSubmit()
File
- includes/
translation.handler.inc, line 1559 - Default translation handler for the translation module.
Class
- EntityTranslationDefaultHandler
- Class implementing the default entity translation behaviours.
Code
public function entityFormLanguageWidgetSubmit($form, &$form_state) {
if (!entity_translation_enabled($this->entityType, $this->bundle)) {
return;
}
$this
->updateFormLanguage($form_state);
$form_langcode = $this
->getActiveLanguage();
foreach (field_info_instances($this->entityType, $this->bundle) as $instance) {
$field_name = $instance['field_name'];
if (isset($form[$field_name]['#language'])) {
$field = field_info_field($field_name);
$previous_langcode = $form[$field_name]['#language'];
// Handle a possible language change: new language values are inserted,
// previous ones are deleted.
if ($field['translatable'] && $previous_langcode != $form_langcode && isset($form_state['values'][$field_name][$previous_langcode])) {
$form_state['values'][$field_name][$form_langcode] = $form_state['values'][$field_name][$previous_langcode];
$form_state['values'][$field_name][$previous_langcode] = array();
}
}
}
}