Score:0

How to add content to the form display of a content type from the GUI?

kz flag

I am constructing a form for a new content type (entity) that implements a survey or questionnaire content type. This fields of this content type is added using the GUI. Each field consists of:

  • A question.
  • A widget to accept the answer that is typed by the user taking the survey.
  • A help text.

All this is fine. I want to add additional content to the form that is seen by the user, viz:

  • A heading that appears between two fields (used to separate different sections of the form).
  • An image to illustrate a question. (If the question is "What animal is this?", the image may show a cat.)

Is there a way to add such additional content to a form display using the GUI?

For Drupal 7, there was the Static Field module that I believe did provide this. I am looking for similar functionality for Drupal 9.

PS: I know that altering the form in code using the Form API and #markup to insert the additional content into the form can be done. However, I am looking for an answer that does not require me to write custom code. If that is not possible, I will of course accept that as an answer.

4uk4 avatar
cn flag
The first task can be done with the Field Group module. This makes it also easier to solve the second task as it introduces more templates you can use in theming (hopefully this doesn't count as coding :-)).
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.