function search_api_elasticsearch_elastica_form_alter in Search API Elasticsearch 7
Implements hook_form_alter().
File
- modules/
elastica/ search_api_elasticsearch_elastica.module, line 118 - Provides an elasticsearch-based service class for the Search API.
Code
function search_api_elasticsearch_elastica_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'search_api_admin_add_index') {
search_api_elasticsearch_attach_ajax_callback($form);
if (isset($form_state['values']) && !empty($form_state['values'])) {
$add_options = search_api_elasticsearch_elastica_add_options($form_state['values']['server']);
if ($add_options != FALSE) {
search_api_elasticsearch_elastica_return_form_options($form, $form_state, array(), 'add');
}
}
}
elseif ($form_id == 'search_api_admin_index_edit') {
$default_values = $form_state['index']->options;
search_api_elasticsearch_attach_ajax_callback($form);
if (!isset($form_state['values'])) {
if (isset($form_state['build_info']['args']) && !empty($form_state['build_info']['args'])) {
$index_obj = reset($form_state['build_info']['args']);
$add_options = search_api_elasticsearch_elastica_add_options($index_obj->server);
if ($add_options != FALSE) {
search_api_elasticsearch_elastica_return_form_options($form, $form_state, $default_values, 'edit');
}
}
}
else {
$add_options = search_api_elasticsearch_elastica_add_options($form_state['values']['server']);
if ($add_options != FALSE) {
search_api_elasticsearch_elastica_return_form_options($form, $form_state, $default_values, 'edit');
}
}
}
}