Score:2

How to add views aware configuration options to a field formatter?

us flag

There is a contrib field formatter module (bg_img_formatter) which has numerous field configuration options. One of these options is a text field which needs to allow for the same views field replacements as the "Rewrite Result:Override the output of this field with custom text" does. But as this is a "field" formatter and not a "Views field" formatter; the formatter class and specifically its viewElements() method is not "views aware".

Wondering what is required to make field formatter options views aware (when used within a view). Do I need to create a views field plugin? Can it add on to the existing field formatter or does it need to replicate all the code that is already here?

cn flag
What do you mean by "views aware"? What features does such a class/method provide that you need?
liquidcms avatar
us flag
"views field replacements as the "Rewrite Result:Override the output of this field with custom text" does"
cn flag
So…you want your entity field formatter classes to have access to Views’ replacement tokens, when said formatters are used to render a field in the context of a Views row, is that if?
liquidcms avatar
us flag
@Clive, Exactly. :)
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.