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.
Someone was looking for a condition similar to the node type one, only for entities types. I figured it wouldn't take me too long, so I gave it a shot. Attached below is a patch that adds this. Right now, it's slightly flawed though. It only works on fieldable entity forms because it uses hook_field_attach_form(). If anyone's got a better solution, I'm all ears.
Comment | File | Size | Author |
---|---|---|---|
#1 | context-entity-type-condition-1722930-1.patch | 4.03 KB | wbobeirne |
Comments
Comment #1
wbobeirne CreditAttribution: wbobeirne commentedPatch attached.
Comment #2
swim CreditAttribution: swim commentedHey wboberine,
We recently required this functionality for targeting all entityforms. I applied the patch to 3.x-dev and all went smoothly. Thank you for uploading this patch!
Can we see this committed to the dev version in the near future?
Cheers,
Comment #3
swim CreditAttribution: swim commentedDidn't notice the duplicate issue; this one was first in google results for me. Updated issue.
Comment #4
swim CreditAttribution: swim commentedComment #5
rcodina CreditAttribution: rcodina commentedIt also works for me on 7.x-3.3+1-dev. Thanks for this!
Comment #6
ron_s CreditAttribution: ron_s commentedPlease review the new patch I added on the Generic entity support thread (https://www.drupal.org/node/1332364#comment-9843157). It extends the patch created by @DamienMcKenna to include functionality similar to node type.
Since it's based on
hook_form_alter
andhook_entity_view_alter
, this should work for all types of entities in both view and edit modes. I've tested it with Entityform and Bean, and worked with both without issue.I'd appreciate if others can test and see if there are any problems that need to be addressed. Thanks.
Comment #7
hass CreditAttribution: hass commented#1332364: Generic entity support