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.
Hello,
It would be nice if the selection handler from entityreference module can be attachable directly on a form element without creating a field. For instance, when adding a new view, the form element 'tagged with' is the perfect use case for this kind of feature. We can implement this feature using a new property such as '#entity_reference' on a textfield element and fulfill it with all required settings needed by entityreference module.
Comment | File | Size | Author |
---|---|---|---|
#1 | entity_reference-attach_selection_handler_on_form_element-2014535-1.patch | 5.03 KB | jkuma |
Comments
Comment #1
jkuma CreditAttribution: jkuma commentedThis is an attempt to solve this feature request. This patch only tackles the textfield form element.
The items bellow describes the list of accepted parameters for the '#entityreference' property:
type: (optional, default: tags) [single|tags]
handler: (optional, default: base) the entity_reference handler.
target_type: the target entity type.
handler_settings: (optional) An array of handler settings such as target_bundles, sort and auto_create.
This is an exemple of implementation:
Comment #2
jkuma CreditAttribution: jkuma commentedComment #3
Jelle_SPatch looks good, tested with crm_core_contact entities and works as expected.
Comment #4
Damien Tournoud CreditAttribution: Damien Tournoud commentedComment #5
Jelle_S@Damien: what work needs to be done to this patch?
Comment #6
Damien Tournoud CreditAttribution: Damien Tournoud commentedI'm going to postpone this to 2.x.
In the need work:
- the access control of the autocomplete needs to be figured out. In the current version of the patch access control is wide open which is not desirable. At the minimum we should add a signed token in the URL
- we should decouple the selection handler from the field system, which we can do in 2.x only
Comment #7
slv_ CreditAttribution: slv_ commentedJust wanted to reference #2029567: Move the functionality to Entity refenrence?, to say that I'll be happy to give a hand to make this happen in a D8 release of the module.
Best regards,
Salva.