Skip navigation
Help

field_bundle_settings

7 field.module 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:

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

5 calls to field_bundle_settings()

2 string references to 'field_bundle_settings'

File

drupal/modules/field/field.module, line 581
Attach custom data fields to Drupal entities.

Code

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;
  }
}