I want to add another field, which needs to be accessible by views (for display and ordering), to the entityreference table field_data_field_FIELDNAME. Structure of that table is:

  • entity_type VARCHAR(128)
  • bundle VARCHAR(128)
  • deleted TINYINT(4)
  • entity_id INT(10)
  • revision_id INT(10)
  • language VARCHAR(32)
  • delta INT(10)
  • field_FIELDNAME_target_id INT(10)

I want to have a column storing DateTime information here, so I can attach information about when this reference was added/ updated for that referenced entity. There also needs to be a way to save the newly added field directly in the array structure for that reference such as:

$node->field_reference['und'][] = array(
  'target_id' => 123,
  'my_new_column' => '2014-03-13 15:29:29'

I know I could solve this by using field_collections or relation module, but both would cause significant performance issues.

1 Answer 1


Gave an approach here https://www.drupal.org/node/2001822#comment-9165509

Hope that it will work for you

  • 2
    thank you, you should probably post the contents in your answer on stackexchange as well to help others, luckily I managed to finish this task a few month ago - but didnt have time to answer my own question. code is here: drupal.org/sandbox/baumeier.it/2078043 Commented Sep 20, 2014 at 20:53
  • Link-only answers are discouraged, even when linking to your own post. Keep the link, but summarize it here, and you'll have my upvote. See drupal.stackexchange.com/help/how-to-answer Commented Oct 11, 2018 at 5:53

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.