0

I have a user reference field as a select list in my content type. When adding node I got a list of usernames. What I want is to display E-mails/ (or other user fields) instead of username. I tried to create entity reference view but it does not show the selected fields in the view either.

2

You are on the good track with solving your problem using Entity Reference Views Display. Once you have that Display type ready, you can edit your Entity reference field to use that Views display.

Your question seems to have two parts, one is displaying user information in Views, and the other is making the Entity reference field use the Entity Reference Views instead of a Select list.

Entity Reference Views in Drupal Core—Needs work

There are efforts to make using Views as Widgets on Entity reference field forms in Drupal Core: View output is not used for entityreference options. You can patch your installation using the patch from that Issue.

Or you can use the already suggested module Entity Reference Views Select until it's all sorted out in core: Similar support to be ported to core. Follow the instructions from the module about how to configure your Entity reference field.

Showing user information in Views

Since your Entity reference field is referencing Users, it makes the most sense to create a View of type User.

Show Users, but don't create a Page or a Block. When you Save the View create a new Display of type Entity Reference.

Add Email and other fields you want to show on the Create node form when selecting users.

Whatever fields you see in this Display, you will see when selecting users on the create/edit node form.

  • Thanks so much for your explaining, yes I figured that this is an issue in a Drupal core and need patching, so I've used the Entity Reference Views Select and it's working fine. – Mohamed Osama Gbril May 30 '18 at 13:37
  • 1
    I'm glad you got it worked out :) – prkos May 30 '18 at 17:50
1

I think it might be a shortcoming of the core entity reference/select list functionality. In Drupal 7 it was working as you would expect but in Drupal 8 it seems not to have the same behaviour.

You can try using entity_reference_views_select which promises to do exactly this

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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