12

please look at these screenshots.
When I use entity reference in a views and autocomplete widget, It worked well.
but when I edit node, it chenged referenced field value as a screenshot 2
Other widgets worked perfect like list or select box (didn't change its value) only has a problem with autocomplete widget.
It automatically changes its value to original(referenced) title I think , but I'm using profile2 I can't change its title.
How can I use autocomplete widget without this problem?
or can I change profile2's title what I want?

Files: 
CommentFileSizeAuthor
#5 entityreference-1896210-5.patch3.94 KBmarcoscano
PASSED: [[SimpleTest]]: [MySQL] 121 pass(es).
[ View ]
#2 entityreference-1896210-2.patch3.84 KBkleinmp
PASSED: [[SimpleTest]]: [MySQL] 119 pass(es).
[ View ]
#1 entityreference-1896210-1.patch3.79 KBJody Lynn
PASSED: [[SimpleTest]]: [MySQL] 119 pass(es).
[ View ]
Screenshot_2.png3.23 KBnicolo2
Screenshot_1.png4.77 KBnicolo2

Comments

Jody Lynn’s picture

Status:Active» Needs review
StatusFileSize
new3.79 KB
PASSED: [[SimpleTest]]: [MySQL] 119 pass(es).
[ View ]

The default value of the autocomplete fields is being set to just the label of the entity (ignoring the views settings).

This patch adds functionality to the views plugin to get the output from the view not just the entity label.

kleinmp’s picture

StatusFileSize
new3.84 KB
PASSED: [[SimpleTest]]: [MySQL] 119 pass(es).
[ View ]

I tested this out and it solves the problem of this issue.

I made a couple of minor tweaks to check if the entity_id is empty before initializing the view and using the php end of line character.

rvilar’s picture

Patch in #2 works for me.

Balbo’s picture

News? Should this be committed?

marcoscano’s picture

Issue summary:View changes
Status:Needs review» Reviewed & tested by the community
StatusFileSize
new3.94 KB
PASSED: [[SimpleTest]]: [MySQL] 121 pass(es).
[ View ]

Same problem here

Patch in #2 doesn't apply cleanly anymore. Re-created a new one with the same code, patch attached.

Marking as RTBC once this solves the problem for me also

tame4tex’s picture

Patch #5 works for me

MustangGB’s picture

Title:Problem with autocomplete widget and Views » When filtering autocomplete by a view #default_value always be the entity title instead of the custom view result (e.g. a field on the entity)

RTBC from me as well.

Chasen’s picture

Confirming Patch #5 works for me as well.

Incidentally, is there an option to further remove the [user:uid] which shows up in parentheses in the autocomplete field on the edit page after searching and selecting the referenced field?

For example, if I have a profile2 called "Main Profile" and reference a street address field for a user (who has the user ID 23) this patch correctly changes the display of the reference entity from "Main Profile (23)" on the edit page, to "123 Fake Street (23)" - however, I think hiding the user ID would be handy as well as possible a further option (or possibly as the default)?

Just to confirm for anyone else searching for this, the patch edits the display on the /node/[node:nid]/edit page, not the view page (/name-of-content). The view display can be handled by an entity reference view and modifying the "Manage Display" page of the content type (/admin/structure/types/manage/[name-of-content-type]/display

phponwebsites’s picture

Ya its working fine.
Similarly i want to set default autocomplete value. The value shouln't displayed with nid. How to set default autocomplete value without nid?