function search_api_live_results_admin_search_edit in Search API live results 7
Form for editing the autocompletion settings for a search.
Parameters
SearchApiLiveResultsSearch $search: The search whose settings should be edited.
See also
search_api_live_results_admin_search_edit_validate()
search_api_live_results_admin_search_edit_submit()
1 string reference to 'search_api_live_results_admin_search_edit'
- search_api_live_results_menu in ./
search_api_live_results.module - Implements hook_menu().
File
- includes/
search_api_live_results.admin.inc, line 207 - Contains page callbacks and related functions for the admin UI.
Code
function search_api_live_results_admin_search_edit(array $form, array &$form_state, SearchApiLiveResultsSearch $search) {
drupal_set_title(t('Edit %search', array(
'%search' => $search->name,
)), PASS_THROUGH);
$form_state['search'] = $search;
$form_state['type'] = $type = search_api_live_results_get_types($search->type);
if (!$type) {
drupal_set_message(t('No information about the type of this search was found.'), 'error');
return array();
}
$form['#tree'] = TRUE;
$form['enabled'] = array(
'#type' => 'checkbox',
'#title' => t('Enabled'),
'#default_value' => $search->enabled,
);
$form['options']['num_results'] = array(
'#type' => 'select',
'#title' => t('Number of results'),
'#options' => drupal_map_assoc(range(1, 20)),
'#default_value' => !empty($search->options['num_results']) ? $search->options['num_results'] : 5,
'#description' => t('How many suggestions should be given.'),
);
$form['options']['conjunction'] = array(
'#type' => 'select',
'#title' => t('Conjunction logic'),
'#options' => array(
'AND' => 'AND',
'OR' => 'OR',
),
'#default_value' => isset($search->options['conjunction']) ? $search->options['conjunction'] : 'AND',
'#description' => t('Search for all terms (AND) or any term (OR)?'),
);
$form['options']['min_length'] = array(
'#type' => 'select',
'#title' => t('Keyword length'),
'#options' => drupal_map_assoc(range(0, 10)),
'#default_value' => isset($search->options['min_length']) ? $search->options['min_length'] : 3,
'#description' => t('The minimum length of a keyword before a search will be initiated.'),
);
$form['options']['auto_hide'] = array(
'#type' => 'select',
'#title' => t('Hide drop menu'),
'#options' => array(
1 => 'Hide',
0 => 'Stay',
),
'#default_value' => isset($search->options['auto_hide']) ? $search->options['auto_hide'] : 1,
'#description' => t('Should the autocomplete menu stay open or hide when it looses focus?'),
);
$form['options']['display'] = array(
'#type' => 'radios',
'#title' => t('Display method'),
'#description' => t('The way the results should be displayed.'),
'#default_value' => !empty($search->options['display']),
'#options' => array(
'view_mode' => t("Use view mode: 'Live result search' to display results"),
'title' => t("Only show title (linked to node)"),
),
'#default_value' => !empty($search->options['display']) ? $search->options['display'] : 'title',
);
$form['options']['caching'] = array(
'#type' => 'checkbox',
'#title' => t('Use memcached caching (Experimental)'),
'#default_value' => !empty($search->options['caching']),
);
$custom_form = empty($form['options']['custom']) ? array() : $form['options']['custom'];
if (!empty($type['config form']) && function_exists($type['config form']) && is_array($custom_form = $type['config form']($custom_form, $form_state, $search))) {
$form['options']['custom'] = $custom_form;
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);
return $form;
}