0

Edit: I think I found the place, just not the method yet. If correct, I will close this question. Sorry.

I have no clue which hook or direction to look into. I would like to have a label or title preprocess function, but that doesnt exist I think.

Its only for a specific content type that I need to show a field's value as title for the referenced nodes.

So it's not about the entity reference widget when editing nodes but rather the title display wherever that reference field is rendering the nodes' titles.

1 Answer 1

2

No code necessary, Drupal has built-in features for this:

  1. Create a new view mode singlefield for the referenced content type foo, showing only the field value
  2. Optionally, create a very minimalistic template for this node--foo--singlefield.html.twig
  3. In /admin/structure/types/manage/foo/display change the view mode of the host entity reference field to Rendered entity, using view mode singlefield
2
  • thats actually a good idea, the problem is more complicated in that I also show entities where the current behaviour is fine, i. e. they dont have that field and should just use their title. if that would be the case, good idea! ;)
    – Alex
    Commented Aug 22, 2019 at 16:05
  • @Alex displays/view modes are configured per node type. So this should work for you, unless I misunderstand?
    – Beebee
    Commented Aug 22, 2019 at 17:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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