1

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?

3

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.

  1. hook_field_settings_form - this is the global settings form, the first page which you encounter when you create a field.
  2. hook_field_instance_settings_form - this the instance level field settings form, usually same options as global settings form but applicable to each instance.

  3. hook_field_widget_settings_form - This is the settings form for the widget, which i have already described above.

  4. 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.

  • Thanks I did not understand the difference between the field type and the widget. Now I understand. :) – ChristophLSA Oct 6 '13 at 20:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.