I have a profile type which uses an autocomplete field which references to another profile. As an entity type i selected user and for filtering the results i use an entity selection with views where i choose what view to filter my content. So far so good , but i've seen that i can pass additional arguments to the view. My question is: How could i pass the input from autocomplete to the referenced view ? ( what should i type in the view arguments field to get the input from autocomplete ? )

  • i think its the other way round : the view provides the values for the autocomplete, not that the autocomplete provides a filter to the view ...
    – mojzis
    Commented Nov 29, 2012 at 10:33
  • i see . is there any possible solution to my question ? I started to modify the query executed by the view , but i do not know how to grab the value of the autocomplete field...
    – Vlasin
    Commented Nov 29, 2012 at 10:48
  • what url does the view get ?
    – Vlasin
    Commented Nov 29, 2012 at 10:51

2 Answers 2


What you're asking doesn't quite make sense if I understand it correctly. You see, the view you're choosing when setting up the field is used before your user has even entered anything in the auto-complete field. So you can't have that be an argument. The view is generated and used prior to any input.

The view is used simply to determine which set of users are available for the auto-complete field. It doesn't make sense to generate the view after the user has already entered in a value, because at that point they've already made a selection anyway.

So - I'm wondering, since you're asking about basing that view on user input, if what you're looking for is simply something like the 'auto-complete' functionality which exists with entity and user/node references. If you select for your field to be Autocomplete, when the user starts typing in a username, a list of related suggestions will automatically appear at the bottom.

enter image description here

Here's an example of a user reference field with autocomplete turned on

enter image description here

  • Yes . It does but i have installed profile2 module and i would like to search after profile's name. That's the reason why i'm using views in the first place... Do you have a better idea how could i do it ?
    – Vlasin
    Commented Dec 3, 2012 at 8:21
  • By the way , If i use an entity selection the sort criteria from view is applicable after the user's input !
    – Vlasin
    Commented Dec 3, 2012 at 10:48
  • And as a reply to your second part of the answer, i need to sort what users may appear in result box of autcomplete field...
    – Vlasin
    Commented Dec 3, 2012 at 10:50
  • Ah, I see. So you're doing it because of the sort. So I assume your sort isn't just alphabetical - the default with auto-complete? I don't see how you can pass the argument to your view through a URL as you're asking because the user will not have entered anything into the autocomplete field yet when the form is launched! So the URL will not know that input yet. Right? That's why I'm confused. There are ways to pass arguments to your view via php (not always recommended) in which case you can use specific fields, but again, the user input will not be available yet when that is evaluated Commented Dec 3, 2012 at 16:18

The solution was to create a module which it will alter the query executed by the view and by grabbing the input from url generated by the autocomplete.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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