2

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.

1 Answer 1

5

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).

3
  • 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. Commented Jul 6, 2016 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... Commented Jul 11, 2018 at 6:46
  • $form['#prefix'] = '<p>bla</p>' works perfectly for me. Commented Jul 11, 2018 at 7:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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