I have a field in an entity that is an Entity Reference with widget Select list.

I have created a view and I want to be able to filter by that field in text format, but when I try to configure the filter I get the options to do it as if it were a number (is less than, is equal to...) and not as a text (contains, start with...).

Any idea of what I am doing wrong?

Edited: Here is screenshot of the filter: enter image description here Thanks!

  • Can you post a screenshot of the filter configuration? Do you get text options on the right and "numerical" options on the left? What type of entity is the referenced entity? What exactly is the Filter you're trying to add? – prkos Apr 19 '19 at 14:25
  • Thanks for your answer. The referenced entity is nodes, where I want to filter is in the title field for searching on the name of the node. – damargon Apr 19 '19 at 21:34

Entity reference fields store the ID of the referenced entity. They don't store anything else about the referenced entity.

You have an Entity reference towards nodes and the data that the ER field stores is the node ID. That is why when you add a filter for that ER field you get the "number" options, because the ID is a number/integer.

But there is a way to add a filter that filters results based on other properties of the referenced entity. When you need extra information you add the Relationship based on the ER field. This introduces all other available info about that entity into your Views.

In your case, you want to add the Relationship for your ER field (Content referenced from fiscal_certificates). Require it if you only want results that don't have that field empty.

After you add the Relationship you can add the Title filter, but make it use the Relationship for the ER field. Title is a text field so you'll get the text options (Contains...).

If you don't use a Relationship on that filter it will search through Titles of your "original" items, but if you use the ER Relationship it will search through the referenced node titles.

  • Thanks a lot! When I try to do what do you say it returns me an error: "Error: Call to a member function label() on null in views_ui_edit_form_get_bucket.". There is something wrong about the entity because I tried to add a relationship in another view and went well. I am going to check the error. – damargon Apr 20 '19 at 21:28
  • Hi again, the problem is that the Id node field had empty values like you adviced me. Your instructions have worked very well, thanks a lot! – damargon Apr 21 '19 at 21:29

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.