Hi,

I have a Content Type (Owner) that has an Entity Reference Field to another Content Type (House). For that form field I use a "Check box" or "Select" widget to show the list of options to the user. By default it uses the Houses' "Title" field. What I would like is to display the Houses' address instead.

So I tried following this article to create a View and Entity Reference
https://www.ostraining.com/blog/drupal/entity-reference-view/

However, it only ever shows the list of Title not the address. As an experiment, I added a block to the view and that block shows the addresses as expected. So I'm sure I'm close but missing something somewhere. Any ideas?

Below are some of my settings. Thanks in advance for the help.

In my View Entity Reference
Format
Format: Entity Reference List
Show: Fields
Fields
Content: Address:address_line1

In my field
Reference Type
Reference Method
Views: Filter by an entity reference view
View used to select the entities:
property_selection_view - Entity Reference

Thanks,
Eddie.

Comments

megan_m’s picture

Are you on Drupal 7 or Drupal 8? Either way, in the display settings of your content type you should be able to select how to display the reference field. Choose "Rendered entity." This will now show the fields from the House entity as you have set up on that content type. You might need to set up a new view mode to show just the address (use Entity View Modes module in Drupal 7 to do that).

Woolwich Web Works: Custom web development

randalx’s picture

Hi,

Thank you for the quick reply. I am using Drupal 8. Unfortunately I'm unsure how to apply your suggestions. I'm a beginner. I can't see where the "Rendered entity" option is in the UI.

Again my goal is that when creating a new node that a reference field selector shows the fields I select rather than the Title field. From what I understood from your response, would that only apply to the content in view mode?

Could the problem be with something to do with the "Manage Form Display"? I see that I have to choose a widget. Right now I choose between check box and select list but I wonder how it would work if my fields where just thumbnails.

BTW, Is there an easy way to include screenshots?

Thanks,
Eddie.

megan_m’s picture

What you can do is make your entity reference display as a view mode. It's in the "Manage Display" settings (not "Manage Form Display"). On the Mange Display screen you should have the option to choose how your reference field is displayed. It is probably set to "label" right now - you'll want to change that to "Rendered Entity". Then you can click on the cog to reveal the settings, and choose a view mode to display it with.

These forums really need some improvements improvement! I'd like to add a screenshot here too.

Woolwich Web Works: Custom web development

randalx’s picture

Hi,

Thanks again for your help.

I gave it a try but it's not affecting the correct view. From what I understand, "Manage Display" will change how the content type displays in "Read" mode (don't know the terminology). Playing with this setting I can see that it in fact changes that display.

However, the display I need to change is when the content type is in "Create or Edit" mode. Shouldn't that then be "Manage form display"? On that page I only seem to be able to change the widget for my reference field. Changing the widget affects the correct page. But what I need is for the Check box widget (or Select list) to show a different field other than the Title field. Maybe it's a limitation of the widgets?

To illustrate, from the article, the author is able to show a name and image field.
Check boxes

Again, I'm new to Drupal so excuse me if I'm missing something from your explanations. I appreciate the time you're taking to help.

megan_m’s picture

Ah, I get you now! There is actually a bug about this:

https://www.drupal.org/node/2174633

You should be able to go into your reference field settings and choose "Filter by an Entity Reference View" as the "reference Method", but that doesn't actually work in Drupal 8. For now you'll have to keep using that label until that fix has been rolled out.

I'm sorry I didn't understand what you were trying to do sooner!

Woolwich Web Works: Custom web development

randalx’s picture

Well that mystery is solved. I guess I'll wait for the bug fix. Thanks for helping me get to the bottom of this!

zooter626’s picture

After trying and searching for a few hours for a reason why this doesn't work in D8 when it works (for the most part) in D7, I was so happy to find this post linking to the bug. Thought I was going a little crazy.

For me, this module is a good workaround for the meantime: https://www.drupal.org/project/entity_reference_views_select

hth

JoshTango’s picture

I would like to know if I can select only the fields I want.  For example in my referenced entity I have 2 fields, one for long description and one for short description.  In he manage display options I would like to be able to only show the short description and not the long description.  The long description would only be used if they click the link and go to the actual content page.

ojchris’s picture

thank you for sharing this module, very effective

JioJio’s picture

Thanks megan_m...

This tip came in handy as I was able to use view mode to only display a field from rendered media entity.

I'm so chuffed

rfletcher73’s picture

When i go into Manage Display, I don't see the Title field.  I'd like to remove that field so I can place the custom fields I've added into the Layout Builder.  I am using a Reference Entity to select Authors of my posts.  I suppose I am trying to do this without having to create a new template.  This seems pretty basic and a common thing to do.  Maybe I am just confused because of all of the different screens I've been through.  Thanks in advance if you have some suggestion.  I am using Drupal 8 and I tried a number of things including the Views but that still displayed the title eventhough I had removed the title from my field output.