function views_autocomplete_filters_filter_hander_value_form in Views Autocomplete Filters 7
Helper function for value_form method for autocomplete filter handlers. Needed to avoid code duplicates.
See also
views_autocomplete_filters_handler_filter_string()
views_autocomplete_filters_handler_filter_combine()
4 calls to views_autocomplete_filters_filter_hander_value_form()
- views_autocomplete_filters_handler_filter_combine::value_form in views/
handlers/ views_autocomplete_filters_handler_filter_combine.inc - Provide a simple textfield for equality.
- views_autocomplete_filters_handler_filter_search_api_fulltext::value_form in views/
handlers/ views_autocomplete_filters_handler_filter_search_api_fulltext.inc - Provide a form for setting the filter value.
- views_autocomplete_filters_handler_filter_search_api_text::value_form in views/
handlers/ views_autocomplete_filters_handler_filter_search_api_text.inc - Provide a form for setting the filter value.
- views_autocomplete_filters_handler_filter_string::value_form in views/
handlers/ views_autocomplete_filters_handler_filter_string.inc - Provide a simple textfield for equality.
File
- ./
views_autocomplete_filters.module, line 153
Code
function views_autocomplete_filters_filter_hander_value_form(&$form, &$form_state, $filter_handler) {
if (empty($form_state['exposed']) || empty($filter_handler->options['expose']['autocomplete_filter'])) {
// It's not an exposed form or autocomplete is not enabled.
return;
}
if (empty($form['value']['#type']) || $form['value']['#type'] !== 'textfield') {
// Not a textfield.
return;
}
// Add autocomplete path to the exposed textfield.
$view_args = !empty($filter_handler->view->args) ? implode('||', $filter_handler->view->args) : 0;
$form['value']['#autocomplete_path'] = 'autocomplete_filter/' . $filter_handler->options['id'] . '/' . $filter_handler->view->name . '/' . $filter_handler->view->current_display . '/' . $view_args;
// Add JS script with core autocomplete overrides to the end of JS files
// list to be sure it is added after the "misc/autocomplete.js" file. Also
// mark the field with special class.
if (!empty($filter_handler->options['expose']['autocomplete_dependent'])) {
$file_path = drupal_get_path('module', 'views_autocomplete_filters') . '/js/views-autocomplete-filters-dependent.js';
drupal_add_js($file_path, array(
'weight' => 99,
));
$form['value']['#attributes']['class'][] = 'views-ac-dependent-filter';
}
}