First and foremost, thank you for your work, awesome module. I have more of a question than anything else.

But is there a reason that Taxonomy index is force enabled when an Entity reference field is referencing a taxonomy term?

Is this a global setting of some sort and setting it for one field would set it for all Entity reference fields that reference a taxonomy term? If that's the case, why show a disabled checkbox, I just don't get it.

I think having this ability would be very useful if you wanted a node to reference a term but not necessarily belong to it.

Thanks,

Vlad

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

weemondo’s picture

Issue summary: View changes

With respect, I would like to bump this issue. Can someone confirm if it is disabled on purpose? Is there is some reason for the time being that we should refrain from using this option?

Damien Tournoud’s picture

I'm not sure what you are asking. Could you try to clarify your question?

Could you post more details about your set up, and/or screenshots about what doesn't work as you expect it to?

weemondo’s picture

The core entity reference module includes a behavior "Taxonomy Index" which applies when referencing taxonomies. This behaviour will create a corresponding term reference for every entity reference created. In the field settings, the checkbox to enable/disable the behaviour plugin contains the option: force_enabled = TRUE. (see file: /plugins/behavior/taxonomy-index.inc)

Therefore, without editing the module's source it is impossible to create an entity reference to a taxonomy term without also creating a taxonomy term reference also.

Marco Vervoort’s picture

I ran into this same issue.
Looking at the issue that created this setting the 'force enabled' flag was intended to make entity-references to taxonomy-terms behave like core references to taxonoym-terms (i.e. items with references are always included in the taxonomy-index for that term) out of the box.

However, the current approach makes the 'taxonomy index' checkbox in the field settings pointless: it is always going to be checked, and is disabled so that it cannot be unchecked. It would be much better if the 'taxonomy index' checkbox was checked by default, but could be unchecked manually.

Patch #3 makes the 'taxonomy index' checkbox functional, but it is unchecked by default. Also, I noticed that if you check or uncheck the checkbox, existing nodes will not be retroactively added or removed from the index (and in the latter case, existing nodes that are already in a taxonomy index for a term will remain in the index for that term, even if you edit the node and select a different taxonomy-term). So as it is, the checkbox is "use with care" when you enable it (possibly this is why it was left disabled in the first place).

ParisLiakos’s picture

Without applying the patch, i run this:

$instance = field_info_instance('node', 'field_my_taxonomy_ref_field', 'my_node_type');
$instance['settings']['behaviors']['taxonomy-index']['status'] = FALSE;
field_update_instance($instance);

Which, disables the behavior, which is also reflected in the field settings page..
But the index is still created on node save :/

ParisLiakos’s picture

i see now..
EntityReferenceBehavior_TaxonomyIndex::buildNodeIndex()
doesn't care for specific field settings.
Even if just one field has the behavior on, this function will add index for every taxonomy_term field on the node..which is unfortunate..also a bug imo

yuraosn’s picture

Thanks for patch #3, but it's not complete.
I made the setting in the admin panel to be viewed and the index was not written.