You are here

function apachesolr_index_config_form in Apache Solr Search 7

Same name and namespace in other branches
  1. 8 apachesolr.admin.inc \apachesolr_index_config_form()
  2. 6.3 apachesolr.admin.inc \apachesolr_index_config_form()

Form builder for the bundle configuration form.

_state

Parameters

array $form:

string $env_id: The machine name of the environment.

Return value

array $form

See also

apachesolr_index_config_form_submit().

1 string reference to 'apachesolr_index_config_form'
apachesolr_status_page in ./apachesolr.admin.inc
Gets information about the fields already in solr index.

File

./apachesolr.admin.inc, line 1282
Administrative pages for the Apache Solr framework.

Code

function apachesolr_index_config_form(array $form, array $form_state, $env_id) {
  $form['config'] = array(
    '#type' => 'fieldset',
    '#title' => t('Configuration'),
    '#collapsible' => TRUE,
  );
  $form['config']['bundles'] = array(
    '#type' => 'markup',
    '#markup' => t('Select the entity types and bundles that should be indexed.'),
  );

  // For future extensibility, when we have multiple cores.
  $form['config']['env_id'] = array(
    '#type' => 'value',
    '#value' => $env_id,
  );
  foreach (entity_get_info() as $entity_type => $entity_info) {
    if (!empty($entity_info['apachesolr']['indexable'])) {
      $options = array();
      foreach ($entity_info['bundles'] as $key => $info) {
        $options[$key] = $info['label'];
      }
      asort($options);
      $form['config']['entities']['#tree'] = TRUE;
      $form['config']['entities'][$entity_type] = array(
        '#type' => 'checkboxes',
        '#title' => check_plain($entity_info['label']),
        '#options' => $options,
        '#default_value' => apachesolr_get_index_bundles($env_id, $entity_type),
      );
    }
  }
  $form['config']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
  );
  return $form;
}