Hey folks,

I have a use case where I have to specifically control the output of the options of Entity Reference based on some "crazy logic" - Performance implications aside for the moment, is there a hook one would use in this module to effectively strip out some of the entities it returns? Or, more accurately control its populated options through a custom module?

For example, a widget may show N1, N2, N3 and based on some logic I have to determine which combination of those to show.

I am no stranger to custom modules but, sheepishly, still coming up to speed on some of the work in the field API and entities. Would you be able to recommend the proper hooks to use to override the options a user can choose?

Thanks so much for any help you can offer.

Comments

amitaibu’s picture

Status: Active » Fixed

> control the output of the options of Entity Reference based on some "crazy logic"

A possible solution is to use hook_query_entityreference_alter(), but your best option is to write your own selection handler. You can have a look at OG 7.2 to see how it overrides the selection handler for it's own logic.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.