I have created an expose filter to display a list of articles written by respective author. For that purpose I have create a view and done following things:

  1. Relationship - Content: Author
  2. Filter Criteria - User: Name (raw)

Now, I am able to get articles written by respective author.

Question: How to make this filter autocomplete? I have used Views Autocomplete Filters module, does not have a luck.


You can add autocomplete to any form:

  1. Use hook_form_alter to set an autocomplete path for the field
  2. Define a menu callback for the autocomplete path in hook_menu
  3. Have the callback query the database

There is a decent write up at http://www.elevatedthird.com/blog/enable-ajax-autocomplete-drupal-7-webform-textfield - make sure you are targeting the right form in hook_form_alter and that your query goes against the users table instead of the node table.

|improve this answer|||||
  • Thanks calebtr for kind reply, i am working on your suggestions. – Rahul Baisane Dec 14 '14 at 12:36

i got an answer,now i can able to apply auto complete for views export filter for that i have created a custom module demo in demo.module i have placed below code

enter image description here

        * Implements hook_form_alter().
        function demo_form_alter(&$form, &$form_state, $form_id) {
        if ($form_id == 'views_exposed_form' && $form['#id'] =='views-exposed-form-game2-page') {
        $form['name']['#autocomplete_path'] = 'name/autocomplete';

        * Implements hook_menu().
        function demo_menu() {
        $items = array();
        $items['name/autocomplete'] = array(
        'title' => 'name autocomplete',
        'page callback' => 'name_autocomplete',
        'access callback' => 'user_access',
        'access arguments' => array('access content'),
        'type' => MENU_CALLBACK,

        return $items;

        function name_autocomplete($string = '') {
        $matches = array();
        if ($string) {
        $result = db_select('users')->fields('users', array('name'))->condition('name', db_like($string) . '%', 'LIKE')->range(0, 10)->execute();
        foreach ($result as $user) {
        $matches[$user->name] = check_plain($user->name);

|improve this answer|||||
  • 2
    It seems an edit/update to your question. Use edit link to update your question. If it's an answer please provide some description to it. – Krishna Mohan Dec 15 '14 at 7:38

Not the answer you're looking for? Browse other questions tagged or ask your own question.