1

I would like to be able to modify the display of any field formatter. To to this I think the best approach is to add settings to all field display formats. Alternatively, I could create my own field formatter that applies to all field types and then show the default display formats within my own display settings.

For example say I want to have a field display settings checkbox that enables a div around the display of any field.

2
  • Why not just override field.tpl.php and implement hook_preprocess_field() to make your changes?
    – Clive
    Apr 16, 2014 at 10:31
  • Thank you Clive. I'm making a module to manipulate the display of fields so this really needs to be done through the field interface. I've found that there's hook_field_formatter_info_alter which looks like you can use it to add your own settings to a formatter but I can't get it to work.
    – Oliver P
    Apr 16, 2014 at 13:20

1 Answer 1

1

I've managed to work this out.

hook_field_formatter_info_alter() isn't properly implemented in Drupal 7. There is however the field_formatter_settings module which exposes two hooks:

  • hook_field_formatter_settings_form_alter()
  • hook_field_formatter_settings_summary_alter()

https://drupal.org/project/field_formatter_settings

Using the dependent modules (e.g. field_delimiter) as examples I was able to achieve what I needed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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