I would like to add a couple paragraphs of predefined text (not an input field) to my contact page. What are my options to do this in Drupal 8? Until this point I've been using JS to get the job done.

up vote 4 down vote accepted

You can create a module, hook on hook_form_alter and add a #prefix to the first input field.

More simple: Create a block with your paragraphs and switch it on for region "(main) content" on the contact page (no programming needed).

  • 1
    That worked nicely. IMO, there should be more clear way to customize contact forms, but this is a fine answer to my question. Thanks for the help. – Jon Carlyon Jul 6 '16 at 15:19
  • Has anyone used a direct $form['#prefix'] in a D8 form? Cause for me it is rendering twice. Once before the form starts and one right after the form starts. Weird... – Pratip Ghosh Jul 11 at 6:46
  • $form['#prefix'] = '<p>bla</p>' works perfectly for me. – Rainer Feike Jul 11 at 7:47

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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