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.
Hi,
What would be the best approach on implementing custom Entity Reference as property instead of as a field?
Thanks,
Mihai
Comments
Comment #1
fmizzell CreditAttribution: fmizzell commentedWaiting for 3.x :) . We are working hard to push an alpha out, and that will come with an entity reference behavior that will work with properties
Comment #2
fmizzell CreditAttribution: fmizzell commentedComment #4
Eugene Fidelin CreditAttribution: Eugene Fidelin commentedAbility to have entity reference behaviour for properties could be very useful feature.
When can it be released?
Comment #5
fmizzell CreditAttribution: fmizzell commented@Eugene Fidelin. The current goal is to get an alpha before BADCamp
Comment #6
mihai_brb CreditAttribution: mihai_brb commentedMeanwhile I am using entityreference_autocomplete in my default_widget. You have almost the same settings as in entity reference field, but in code.
https://drupal.org/project/entityreference_autocomplete
When you need it for multiple properties you could write a generic property behavior with some naming convention for the property like id_{entity}. If anyone is interested I will be happy to elaborate.
Best,
Mihai
Comment #7
elpino CreditAttribution: elpino as a volunteer commentedI'm interested!!
I've been searching all over and I can't find a good source on how to create a property behaviour that let's me reference entities using the entityreference_autocomplete module.
Mind you I am NOT looking to add a field, what I want is a property.
If you could please elaborate that would be great @mihai_brb !
Comment #8
mihai_brb CreditAttribution: mihai_brb commentedHi elpino,
Check out this module that has a few field replica behaviors. There is one for referencing entities.
https://www.drupal.org/project/eckextend
You can check the code to see how to implement a custom behavior. But if you only need to add a reference property the module should be sufficient.
Best,
Mihai