Skip to content

Custom view mode settings are overridden on every feature revert #60

Description

@willzyx-dev

Original issue on d.o https://www.drupal.org/node/2918191

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions