Score:1

equivalent of hook_field_widget_form_alter() for field formatters?

by flag

There's a hook hook_field_widget_form_alter() for altering a field widget, but I can't see anything equivalent for altering a field formatter's output.

cn flag
There isn't a direct equivalent, but `hook_preprocess_field` is often enough, depending on the formatter - what type(s) are you looking to intercept?
4uk4 avatar
cn flag
If you want to alter the output of the field formatters as early as possible before any other processing and rendering starts, you can use [hook_entity_display_build_alter](https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Entity%21entity.api.php/function/hook_entity_display_build_alter/9). I've linked the D9 version because the example code fits the question better than the D10 version.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.