Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Preconditions:
- A site with (let's say) 4 content types.
- An entityreference field:
- which accepts linking only to 2 of those content types;
- is configured to display "Add" and "Search" links beneath the widget via references dialog;
- with a views-based autocomplete widget (eg. for displaying the content type besides the node title on the autocomplete search results).
- The view behind the autocomplete has a contextual filter for the content types, to allow different fields using the same view with arguments like "firsttype+secondtype".
Problem:
- The "Add" link is not present.
Solution:
- Instead of a contextual filter on the view, add a real
type
filter to that display of the view which is being used on this field. With this approach, references_dialog will have information about the acceptable content types. With the contextual filter/argument approach, references_dialog cannot have this information, so it is not displaying the "Add" links.
(Couldn't find other places like a documentation page or a README to add this information, that's why I'm posting it here.)
Comments