function locale_field_entity_form_submit
Handles field language on submit for the given entity type.
Checks if Locale is registered as a translation handler and handle possible language changes.
2 calls to locale_field_entity_form_submit()
- locale_field_comment_form_submit in modules/
locale/ locale.module - Form submit handler for comment_form().
- locale_field_node_form_submit in modules/
locale/ locale.module - Form submit handler for node_form().
File
-
modules/
locale/ locale.module, line 429
Code
function locale_field_entity_form_submit($entity_type, $form, &$form_state) {
if (field_has_translation_handler($entity_type, 'locale')) {
$entity = (object) $form_state['values'];
$current_language = entity_language($entity_type, $entity);
list(, , $bundle) = entity_extract_ids($entity_type, $entity);
foreach (field_info_instances($entity_type, $bundle) as $instance) {
$field_name = $instance['field_name'];
$field = field_info_field($field_name);
$previous_language = $form[$field_name]['#language'];
// Handle a possible language change: new language values are inserted,
// previous ones are deleted.
if ($field['translatable'] && $previous_language != $current_language) {
$form_state['values'][$field_name][$current_language] = $entity->{$field_name}[$previous_language];
$form_state['values'][$field_name][$previous_language] = array();
}
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.