diff --git a/includes/scald.pages.inc b/includes/scald.pages.inc index 79250da..14b568c 100644 --- a/includes/scald.pages.inc +++ b/includes/scald.pages.inc @@ -352,8 +352,24 @@ function scald_atom_add_form_options_submit(&$form, &$form_state) { // Let entity add its properties to the atom. entity_form_submit_build_entity('scald_atom', $atom, $form['atom' . $delta], $form_state); - $atom->title = $form_state['values']['atom' . $delta]['title']; $atom->actions = $form_state['values']['atom' . $delta]['actions']; + + // Our form structure is different from standard Entity form because we + // support multiple entities in a single form, so we have to process special + // stuffs here. Except when comes the Title module, which is a field. + $update_title = TRUE; + if (module_exists('title')) { + $fr_info = title_field_replacement_info('scald_atom'); + if (isset($fr_info['title'])) { + // If Title field replaces the title property, it takes care of the sync + // in title_field_attach_submit() so we don't have to do anything. + $update_title = FALSE; + } + } + if ($update_title) { + $atom->title = $form_state['values']['atom' . $delta]['title']; + } + // Then save it... scald_atom_save($atom); } diff --git a/includes/scald.translation_handler.inc b/includes/scald.translation_handler.inc index b2e4c9e..5dc7061 100644 --- a/includes/scald.translation_handler.inc +++ b/includes/scald.translation_handler.inc @@ -6,12 +6,7 @@ */ /** - * Scald Atom translation handler. - * - * This class is registered in scald.module using the translation - * property the Entity Translation module uses via hook_entity_info(). - * - * @see scald_entity_info() + * Class implementing the entity translation behaviours for Scald Atom. */ class EntityTranslationScaldHandler extends EntityTranslationDefaultHandler { diff --git a/scald.module b/scald.module index c16009c..86476e5 100644 --- a/scald.module +++ b/scald.module @@ -1670,11 +1670,6 @@ function scald_entity_info() { ), ); - $translatable_field_callbacks = array( - 'sync_get' => "scald_text_field_sync_get", - 'sync_set' => "scald_text_field_sync_set", - ); - $return = array( 'scald_atom' => array( 'label' => t('Atoms'), @@ -1713,7 +1708,6 @@ function scald_entity_info() { 'label' => t('Title'), 'description' => '', ) + $translatable_field_instance, - 'callbacks' => $translatable_field_callbacks, ), ), 'efq bundle conditions' => TRUE, @@ -1754,26 +1748,6 @@ function scald_entity_info() { } /** - * Sync callback for the text field type. Used by Title API to make title translatable. - */ -function scald_text_field_sync_get($entity_type, $entity, $legacy_field, $info, $langcode) { - $value = NULL; - $field_name = $info['field']['field_name']; - if (!empty($entity->{$field_name}[$langcode]) && is_array($entity->{$field_name}[$langcode])) { - $items = $entity->{$field_name}[$langcode]; - $value = !empty($items[0]['value']) ? $items[0]['value'] : NULL; - } - return array($legacy_field => $value); -} - -/** - * Sync back callback for the text field type. Used by Title API to make title translatable. - */ -function scald_text_field_sync_set($entity_type, $entity, $legacy_field, $info, $langcode) { - $entity->{$legacy_field} = $entity->{$info['field']['field_name']}[$langcode][0]['value']; -} - -/** * Implements hook_entity_property_info(). */ function scald_entity_property_info() {