Closed (fixed)
Project:
Views (for Drupal 7)
Version:
6.x-2.x-dev
Component:
user data
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
22 Aug 2008 at 00:14 UTC
Updated:
3 Jul 2009 at 21:33 UTC
Please see #295556: Userreference with allowed values from View.
I ran into a situation when patching the CCK userreference field where I needed to use a string filter for autocomplete purposes, and found that the name field has no filter associated with it. This simply adds it to the hook_views_data implementation. We figured others may also have a use for it.
| Comment | File | Size | Author |
|---|---|---|---|
| user-name-filter.patch | 446 bytes | CPyle |
Comments
Comment #1
yched commentedMany thanks, CPyle. I'll try to actually test your patch asap.
[edit - doh, I should go to sleep - this was intended for #295556: Userreference with allowed values from View ]
Comment #2
merlinofchaos commentedNote that the UID filter already has an autocomplete field. Why add another one that will be less efficient?
Comment #3
CPyle commentedI'll describe the use case.
I made a patch to CCK Userreference to allow using views to populate the allowed users you can select. It's autocomplete functionality is already built into the widget, it expects to just provide a string to the 'potential references' function. The views version of this function gets the view normally and then simply applies the string as a filter to the name field in the query with a 'contains' or 'startswith' operator (If such a string is provided).
If you know a better way to go about doing this that doesn't drastically change the CCK codebase, I'd defer to your judgement. My userreference patch is already adding a string filter handler to 'users'/'name' via hook_views_data_alter(). This was the method that required the fewest changes to CCK.
This is the same method CCK nodereference uses, only it applies a string filter to a node's title.
Comment #4
merlinofchaos commentedYou did not answer my question, instead you told me about CCK which isn't involved in this issue. I'm very confused.
Comment #5
CPyle commented