field_bundle_settings

  1. drupal
    1. 8
    2. 7
Versions
7 – 8 field_bundle_settings($entity_type, $bundle, $settings = NULL)

Gets or sets administratively defined bundle settings.

For each bundle, settings are provided as a nested array with the following structure:

<?php
array(
  'view_modes' => array(
    // One sub-array per view mode for the entity type:
    'full' => array(
      'custom_display' => Whether the view mode uses custom display
        settings or settings of the 'default' mode,
    ),
    'teaser' => ...
  ),
  'extra_fields' => array(
    'form' => array(
      // One sub-array per pseudo-field in displayed entities:
      'extra_field_1' => array(
        'weight' => The weight of the pseudo-field,
      ),
      'extra_field_2' => ...
    ),
    'display' => array(
      // One sub-array per pseudo-field in displayed entities:
      'extra_field_1' => array(
        // One sub-array per view mode for the entity type, including
        // the 'default' mode:
        'default' => array(
          'weight' => The weight of the pseudo-field,
          'visible' => TRUE if the pseudo-field is visible, FALSE if hidden,
        ),
        'full' => ...
      ),
      'extra_field_2' => ...
    ),
  ),
);
?>

Parameters

$entity_type The type of $entity; e.g., 'node' or 'user'.

$bundle The bundle name.

$settings (optional) The settings to store.

Return value

If no $settings are passed, the current settings are returned.

Related topics

▾ 4 functions call field_bundle_settings()

field_ui_display_overview_form_submit in modules/field_ui/field_ui.admin.inc
Submit handler for the display overview form.
field_ui_field_overview_form_submit in modules/field_ui/field_ui.admin.inc
Submit handler for the field overview form.
field_view_mode_settings in modules/field/field.module
Returns view mode settings in a given bundle.
_field_info_prepare_extra_fields in modules/field/field.info.inc
Prepares 'extra fields' for the current run-time context.

Code

modules/field/field.module, line 613

<?php
function field_bundle_settings($entity_type, $bundle, $settings = NULL) {
  $stored_settings = variable_get('field_bundle_settings', array());

  if (isset($settings)) {
    $stored_settings[$entity_type][$bundle] = $settings;

    variable_set('field_bundle_settings', $stored_settings);
    field_info_cache_clear();
  }
  else {
    $settings = isset($stored_settings[$entity_type][$bundle]) ? $stored_settings[$entity_type][$bundle] : array();
    $settings += array(
      'view_modes' => array(), 
      'extra_fields' => array(),
    );
    $settings['extra_fields'] += array(
      'form' => array(), 
      'display' => array(),
    );

    return $settings;
  }
}
?>