public function SearchApiEntityDataSourceController::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_entity.inc, line 273 - Contains the SearchApiEntityDataSourceController class.
Class
- SearchApiEntityDataSourceController
- Represents a datasource for all entities known to the Entity API.
Code
public function configurationForm(array $form, array &$form_state) {
$options = $this
->getAvailableBundles();
if (!$options) {
return FALSE;
}
$form['bundles'] = array(
'#type' => 'checkboxes',
'#title' => t('Bundles'),
'#description' => t('Restrict the entity bundles that will be included in this index. Leave blank to include all bundles. This setting cannot be changed for enabled indexes.'),
'#options' => array_map('check_plain', $options),
'#attributes' => array(
'class' => array(
'search-api-checkboxes-list',
),
),
'#disabled' => !empty($form_state['index']) && $form_state['index']->enabled,
);
if (!empty($form_state['index']->options['datasource'])) {
$form['bundles']['#default_value'] = drupal_map_assoc($form_state['index']->options['datasource']['bundles']);
}
return $form;
}