You are here

public function SearchApiCombinedEntityDataSourceController::configurationForm in Search API 7

Form constructor for configuring the datasource for a given index.

Parameters

array $form: The form returned by configurationForm().

array $form_state: The form state. $form_state['index'] will contain the edited index. If this key is empty, then a new index is being created. In case of an edit, $form_state['index']->options['datasource'] contains the previous settings for the datasource.

Return value

array|false A form array for configuring this callback, or FALSE if no configuration is possible.

Overrides SearchApiAbstractDataSourceController::configurationForm

File

includes/datasource_multiple.inc, line 253
Contains SearchApiCombinedEntityDataSourceController.

Class

SearchApiCombinedEntityDataSourceController
Provides a datasource for indexing multiple types of entities.

Code

public function configurationForm(array $form, array &$form_state) {
  $form['types'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Entity types'),
    '#description' => t('Select the entity types which should be included in this index.'),
    '#options' => array_map('check_plain', search_api_entity_type_options_list()),
    '#attributes' => array(
      'class' => array(
        'search-api-checkboxes-list',
      ),
    ),
    '#disabled' => !empty($form_state['index']),
    '#required' => TRUE,
  );
  if (!empty($form_state['index']->options['datasource']['types'])) {
    $form['types']['#default_value'] = $this
      ->getEntityTypes($form_state['index']);
  }
  return $form;
}