21

Pretty simple question really, but is there any benefit to using a core term reference field over an Entity Reference field?

Obviously tagging is not really an option with Entity Reference, but I've used the Inline Entity Form for creating new terms from a node page and it works fine (I prefer it over tagging if my terms have fields).

tl;dr

Apart from tagging are there any benefits/caveats with using Entity Reference over Term Reference for referencing taxonomy terms?

1
  • I should probably mention I am aware of things like Hierarchical Select requiring term reference fields, I'm just talking about general taxonomy references.
    – Chapabu
    Commented Jan 4, 2013 at 14:22

2 Answers 2

21

Swings and roundabouts really, it depends on your use case...

Behind the scenes there's essentially no difference - both field types relate one entity to another by way of an ID, so it really comes to down which type provides you with the 'frills' you need/want.

As you mentioned Taxonomy has the open tagging widget, which is nice, but then Entity Reference has Views integration (by way of Entity Reference View Widget) which means you can define as complex a view as you like for your selection widget. Also very nice.

And then there's Inline Entity Form which you also mentioned. That's a superb tool obviously, but only really useful if you need it in your project.

What Taxonomy has going for it is that it's part of core, and doesn't require a bunch of other modules installed to work. But then in a normal Drupal build a lot of those modules will probably already be there. It also maintains a term index table for nodes which can help with performance, but obviously only if you're relating your terms to node types.

I think your choice is going to come down to what widgets/formatters you need for a particular situation to be honest, it's too tight to call :)

1
  • 2
    Yeah, this is what I kind of figured :) I've been using Entity reference for terms for a while - just wondered if there was something that was gonna go wrong somewhere down the line. Tagging is neat, but save blog/news sections I've never had a killer need for it that wasn't better solved with an IEF.
    – Chapabu
    Commented Jan 4, 2013 at 14:38
10

Just thought I would add to this discussion that it looks like term reference will be deprecated in D8. So it seems with all the pros of entity reference you may want to avoid using term reference on new sites as it will just be more of a pain to migrate later when you move to D8.

https://drupal.org/node/1847596

0

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.