You are here

function breadcrumb_extra_field_admin in Breadcrumb Extra Field 7

Admin form.

2 string references to 'breadcrumb_extra_field_admin'
breadcrumb_extra_field_field_extra_fields in ./breadcrumb_extra_field.module
Implements hook_field_extra_fields().
breadcrumb_extra_field_menu in ./breadcrumb_extra_field.module
Implements hook_menu().

File

./breadcrumb_extra_field.admin.inc, line 11
Breadcrumb extra field admin form.

Code

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