Hi,
I've a node with a user reference cck field.
That cck field is configured to query a view to display a list of users in a dropdown list.
The view is a user list with just two fields name forename and familyname (both profile fields). Previewing the views should a list of forename / familynames correctly.
However, when one adds a new node, the user reference drop down list contains:
FamilyName - Forename - Name: USERNAME
I'd like to remove the dashes, and the last part "Name: username".
After searching the issue Q for a while, I added "uid" as a hidden field to the view, but that made no difference.
Also: I tried overriding the display of a field with views-view-field--VIEWNAME--default--value.tpl.php, but this too is ignored in the user reference dropdown list.
How does one format the fields in the user reference selection list, and remove the trailing user name?
Thanks in advance..
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | view_always_contains_username-897950-9.patch | 711 bytes | lendude |
Comments
Comment #1
mtbradle commentedsubscribing
Comment #2
dawehnerI guess this is a userreference problem. I cannot think of anything which changed here.
Comment #3
boran commentedDereine: so you have seen this issue too?
Comment #4
dawehnerNo, i just hanged around in the issue queue.
Comment #5
petermilad commentedsubscribing
Comment #6
schultetwin commentedI believe the code that is causing this is in the userreference.module at line 742. The userreference module must have the user name in order to validate the field.
Anyway, I've fixed the issue by adding the user name as a display field to my view and then just excluding it from the view. That works fine, although a bit hackish.
Comment #7
boran commentedThat explains things, and adding the user to the view works as suggested.
I'll change the status to "patch", since the fix works, but the maintainers might like to consider your change.
Comment #8
sdragnev commentedboran: Did you manage to get rid of the dashes and if so how?
UPDATE: Nevermind, figured it out. Couldn't use a table style in the view.
Switching to unformatted and then using Row Style to set the separator did the job.
Comment #9
lendudeI ran into the same problem. I found the same work-around as schultetwin, but it indeed feels hackish and a tiny bit counterintuitive (add 'name' to your view to remove it from the display...)
I wrote a patch that should fix the issue. The 'name' field is still added but by sending the option 'exclude' it is not displayed (so pretty much what the workaround did, except programmatically). This feels right, since whoever made the view didn't want to show the name in the first place (or they would have added it themselves).
I changed the line
$view->add_item($display, 'field', 'users', 'name');
to:
$view->add_item($display, 'field', 'users', 'name', array('exclude' => 1));
I made the patch from 2.9 but the same issue is in 3.x
Len
Comment #10
aaustin commentedAgreed, works but I never would have figured it out without Google and this issue queue.
Comment #11
kscheirerJust ran into this too. It is indeed weird, but the "add user: name field, and then exclude from display" trick works. Setting to "needs review" since a patch is posted and looks reasonable.