1 locale.module locale_field_node_form_submit($form, &$form_state)

Form submit handler for node_form().

Checks if Locale is registered as a translation handler and handle possible node language changes.

This submit handler needs to run before entity_form_submit_build_entity() is invoked by node_form_submit_build_node(), because it alters the values of attached fields. Therefore, it cannot be a hook_node_submit() implementation.


core/modules/locale/locale.module, line 230
Add language handling functionality and enables the translation of the user interface to languages other than English.


function locale_field_node_form_submit($form, &$form_state) {
  if (field_has_translation_handler('node', 'locale')) {
    $bundle = $form_state['values']['type'];
    $node_language = $form_state['values']['langcode'];

    foreach (field_info_instances('node', $bundle) as $instance) {
      $field_name = $instance['field_name'];
      $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 != $node_language) {
        $form_state['values'][$field_name][$node_language] = $form_state['values'][$field_name][$previous_langcode];
        $form_state['values'][$field_name][$previous_langcode] = array();