1 field_ui.admin.inc field_ui_view_mode_enable($entity_type, $bundle, $view_mode_name, $redirect = TRUE)

Menu callback: Enables the manage displays UI for a display mode.

File

core/modules/field_ui/field_ui.admin.inc, line 2395
Administrative interface for custom field type creation.

Code

function field_ui_view_mode_enable($entity_type, $bundle, $view_mode_name, $redirect = TRUE) {
  // Be sure we get the bundle.
  $bundle = field_extract_bundle($entity_type, $bundle);

  // Get current bundle settings.
  $bundle_settings = field_bundle_settings($entity_type, $bundle);

  // Get display mode settings.
  $view_mode_settings = field_view_mode_settings($entity_type, $bundle);

  // Initialize the newly customized display mode with the display settings
  // from the default display mode.
  _field_ui_add_default_view_mode_settings($entity_type, $bundle, $view_mode_name, $bundle_settings);
  $bundle_settings['view_modes'][$view_mode_name]['custom_settings'] = TRUE;

  // Save updated bundle settings.
  field_bundle_settings($entity_type, $bundle, $bundle_settings);

  // Set a friendly message.
  $entity_info = entity_get_info($entity_type);
  $label = $entity_info['view modes'][$view_mode_name]['label'];
  $path = _field_ui_bundle_admin_path($entity_type, $bundle) . '/display';
  $url = url($path . '/' . $view_mode_name);
  $message = t('The display mode %name can now be <a href="@url">customized</a>.', array('%name' => $label, '@url' => $url));
  backdrop_set_message($message);

  // Clear the menu cache to add display mode to administration menu.
  menu_cache_clear();

  if ($redirect) {
    // Reload the current page.
    backdrop_goto($path);
  }
}