I have all message related configuration in my project managed with features module. I noticed that my custom view mode settings are overridden on every feature revert.
This seems be caused by message_notify_field_attach_create_bundle() that doesn't take in account view modes other than 'email subject' and 'email body'; when it save the display settings for the extra fields (message__message_text__0 and message__message_text__1) it override (and delete) the other view modes configuration

/**
 * Implements hook_field_attach_create_bundle().
 *
 * We cannot easily set the the visibilty of extra fields, so we set the
 * bundle settings upon creation of new message bundle.
 */
function message_notify_field_attach_create_bundle($entity_type, $bundle) {
  if ($entity_type != 'message') {
    return;
  }

  $bundle_settings = field_bundle_settings('message', $bundle);
  $display = &$bundle_settings['extra_fields']['display'];

  $visible = array('visible' => TRUE, 'weight' => 0);
  $hidden = array('visible' => FALSE, 'weight' => 0);

  // custom setting are overridden -->
  $display['message__message_text__0'] = array(
    'message_notify_email_subject' => $visible,
    'message_notify_email_body' => $hidden,
  );

  // custom setting are overridden -->
  $display['message__message_text__1'] = array(
    'message_notify_email_subject' => $hidden,
    'message_notify_email_body' => $visible,
  );

  field_bundle_settings('message', $bundle, $bundle_settings);
}

this function should handle only the needed extra fields for the view mode managed by message_notify without override custom configuration

CommentFileSizeAuthor
#3 custom_view_mode-2918191-2.patch1.03 KBwillzyx

Comments

willzyx created an issue. See original summary.

willzyx’s picture

Issue summary: View changes
willzyx’s picture

Status: Active » Needs review
StatusFileSize
new1.03 KB
willzyx’s picture

Title: Custom view mode settings are deleted on every feature revert » Custom view mode settings are overridden on every feature revert
Issue summary: View changes
bluegeek9’s picture

Status: Needs review » Closed (outdated)