You are here

breadcrumb_extra_field.admin.inc in Breadcrumb Extra Field 7

Breadcrumb extra field admin form.

File

breadcrumb_extra_field.admin.inc
View source
<?php

/**
 * @file
 * Breadcrumb extra field admin form.
 */

/**
 * Admin form.
 */
function breadcrumb_extra_field_admin() {
  $form = array();
  $entity_info = entity_get_info();
  $admin = variable_get(BREADCRUMB_EXTRA_FIELD_ADMIN, array());
  $allowed_entity_types = unserialize(BREADCRUMB_EXTRA_FIELD_ALLOWED_ENTITY_TYPES);
  $form[BREADCRUMB_EXTRA_FIELD_ADMIN] = array(
    '#type' => 'fieldset',
    '#title' => t('Select entity types which are going to use the breadcrumb extra field'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
    '#tree' => TRUE,
    '#description' => t('Enable extra field for these entity types and bundles.'),
  );
  foreach ($entity_info as $entity_type_key => $entity_type) {
    $bundle_options = array();

    // Skip not allowed entity types.
    if (in_array($entity_type_key, $allowed_entity_types)) {
      foreach ($entity_type['bundles'] as $bundle_key => $bundle) {
        $bundle_options[$bundle_key] = $bundle['label'];
      }
      $form[BREADCRUMB_EXTRA_FIELD_ADMIN][$entity_type_key] = array(
        '#type' => 'checkboxes',
        '#title' => $entity_type['label'],
        '#options' => $bundle_options,
        '#default_value' => !empty($admin[$entity_type_key]) ? array_keys(array_filter($admin[$entity_type_key])) : array(),
      );
    }
  }
  return system_settings_form($form);
}

Functions

Namesort descending Description
breadcrumb_extra_field_admin Admin form.