6

I am attempting to make a contact form in Drupal 8 using "Contact forms" included in core. I'm struggling to figure out how to really customize it, like adding radio buttons or check boxes - does this have to be done through the theme_name.theme file? If so, can someone give me an example of adding elements to the page? I'm new to Drupal so thanks for helping out.

10

In Drupal 8, contact forms are entities listed in admin/structure/contact. Once you created the new contact form, on that page select Manage fields in the Operations column; it's a drop-down selector, so you will need to select it to see that operation, since the default operation for contact forms you create is Edit.

screenshot

On the page you will see, you can add new fields.

The tricky part is understanding how to show checkboxes: You need to select the right field type. For example, if you want to show 4 checkboxes, then you select Text (list) as field type.

screenshot

Enter the 4 values you want to show, and enter 4 as Allowed number of values.

screenshot

To show it as checkboxes, you go to the Manage form display of your contact form (in my case, admin/structure/contact/manage/test/form-display, since test is the machine name of the contact form I created). For the field you created, it should show the following.

screenshot

Change it to Check boxes / radio buttons and save.

screenshot

Since the allowed values are 4, the contact form will show checkboxes, not radio buttons.

  • 1
    You sure are thorough! Thank you very much for such a detailed answer on such a simple question, it worked perfectly. – Jon Carlyon Apr 11 '16 at 15:22

Your Answer

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

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