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.

  • 1
    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 :-)).
    – 4uk4
    Nov 23, 2022 at 10:16


Your Answer

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

Browse other questions tagged or ask your own question.