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.
Looking at field_ui_field_settings_form(), we discover that hook_field_settings_form() only lets the module defining the field append additional settings to the field. External modules should be able to append additional settings to the defined fields.
Currently, if a contributed module (like Field Permissions) wants to add field settings, it is required to do a form_alter(). We should fix this by making it so that hook_field_settings_form() applies to all modules, not just the module that's defining the field.
Comments
Comment #1
RobLoachHit #945524: Field formatter settings hooks in core
Comment #2
webankit CreditAttribution: webankit commentedhook_field_settings_form() & hook_field_instance_settings_form can only be invoked by the modules defining field.
#1 will add a similar functionality for formatter settings hooks. These issues are related but are not duplicate.
Comment #3
RobLoach#945524: Field formatter settings hooks in core
Comment #4
andyposti think field settings (and instance) are different things
Comment #5
mrweiner CreditAttribution: mrweiner commentedHas there been any development on this? I'd definitely suggest this as an addition to D8 at least, if not also D7. I also agree that this should be considered as separate from, albeit related to, the linked issue.
I really need a way to alter a field's settings based on role, and a hook like this is the only way that I can find to accomplish this. Unless, of course, somebody else has an alternative. I'm sure I'm not the only person who's ended up on this page while searching for a way to alter a field's settings via a hook.
Comment #6
attiks CreditAttribution: attiks commented#945524: Field formatter settings hooks in core is committed to D8, so this can be done as well
Comment #7
John Pitcairn CreditAttribution: John Pitcairn commented+1 from me...
Comment #8
andypostSuppose this already done in #1735118: Convert Field API to CMI
We have
hook_entity_OPERATION()
to alter anything and form alters fo UI