From 6c430be599e2dbe21cb077868d70a86f1ced0e29 Mon Sep 17 00:00:00 2001
From: Teun van Veggel <teun@nuezweb.com>
Date: Sat, 9 Feb 2013 18:01:33 +0100
Subject: [PATCH] Issue #1905140 by nuez: Fixed Title module compatibility

---
 includes/fape.inc |   21 ++++++++++++++++++++-
 1 files changed, 20 insertions(+), 1 deletions(-)

diff --git a/includes/fape.inc b/includes/fape.inc
index 316a4cb..8fae5d1 100644
--- a/includes/fape.inc
+++ b/includes/fape.inc
@@ -34,7 +34,26 @@ function edit_field_edit_form(&$form, &$form_state) {
 function edit_build_entity($form, &$form_state) {
   $entity = clone $form_state['entity'];
   field_attach_submit($form_state['entity_type'], $entity, $form, $form_state, array('field_name' =>  $form_state['field_name']));
-
+	
+	// The title module needs to update the 'legacy field' values as well.
+	// @see title_field_attach_submit in title.module.
+	if(module_exists('title')){
+		$entity_type = $form_state['entity_type'];
+		$fr_info = title_field_replacement_info($entity_type);
+		if (!empty($fr_info)) {
+			$values = $form_state['values'];
+			$values = drupal_array_get_nested_value($values, $form['#parents']);
+			$langcode = title_entity_language($entity_type, $entity);
+			foreach ($fr_info as $legacy_field => $info) {
+					$field_name = $info['field']['field_name'];		
+					if (!empty($info['callbacks']['submit'])) {
+						$info['callbacks']['submit']($entity_type, $entity, $legacy_field, $info, $langcode, $values);
+					}
+					drupal_static_reset('field_language');
+					title_field_sync_get($entity_type, $entity, $legacy_field, $info, $langcode);
+			}
+		}
+	}
   // @todo Refine automated log messages and abstract them to all entity
   //   types: http://drupal.org/node/1678002.
   if ($form_state['entity_type'] == 'node' && $entity->revision && !isset($entity->log)) {
-- 
1.7.0.4

