function search_api_admin_add_index_submit in Search API 7
Form submission handler for search_api_admin_add_index().
See also
search_api_admin_add_index_validate()
File
- ./
search_api.admin.inc, line 869 - Administration page callbacks for the Search API module.
Code
function search_api_admin_add_index_submit(array $form, array &$form_state) {
form_state_values_clean($form_state);
$values = $form_state['values'];
if (!empty($form_state['step_one'])) {
$values += $form_state['step_one'];
unset($form_state['step_one']);
}
// The type was changed (or the form submitted without JS for the first time).
// If the new type has a configuration form, we have to display it now.
$datasource = search_api_get_datasource_controller($values['item_type']);
if ($values['item_type'] != $values['old_type']) {
$datasource_form = array();
if ($datasource
->configurationForm($datasource_form, $form_state)) {
unset($values['options']['datasource']);
$form_state['step_one'] = $values;
$form_state['rebuild'] = TRUE;
drupal_set_message(t('Please specify further configuration options.'));
return;
}
}
// If the current type has a configuration form, call the datasource
// controller's config submit callback.
if ($values['datasource_config']) {
$datasource
->configurationFormSubmit($form['datasource'], $values['options']['datasource'], $form_state);
}
// Validation of whether a server is set for the index is done in the
// SearchApiIndex::save() method.
search_api_index_insert($values);
drupal_set_message(t('The index was successfully created. Please set up its indexed fields now.'));
$form_state['redirect'] = 'admin/config/search/search_api/index/' . $values['machine_name'] . '/fields';
}