Difference between field form hooks for settings I created a field for my module and now I want to create settings for this field.

Now I found four hooks:


hook_field_settings_form
hook_field_instance_settings_form
hook_field_widget_settings_form
hook_field_formatter_settings_form


What is the difference between these hooks?

I think "formatter_settings" is for settings to change the later display of the output on the entity. Right? And the other hooks?
Let me explain to you briefly what each of them does. Basically a field has two prime components, one is widget and the other is formatter. The widget is the input part( like checkbox, select list, textfield). This helps field to grab data from the user. The other one is formatter. Formatters are responsible for how output is rendered by that field.

Now regarding the hooks you mentioned:

I will try and help you visualise these by comparing to the steps which you encounter while creating a field.


hook_field_settings_form - this is the global settings form, the first page which you encounter when you create a field.
hook_field_instance_settings_form - this the instance level field settings form, usually same options as global settings form but applicable to each instance.
hook_field_widget_settings_form - This is the settings form for the widget, which i have already described above.
hook_field_formatter_settings_form - This is the settings form for the formatter. This exposes options that will be used to render the value of the field.


Observe closely the forms and steps that come up while you create a field through UI in Drupal and you will gain more insights on these components. hope that helps.