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.
1 Answer
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.
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.
Enter the 4 values you want to show, and enter 4 as Allowed number of values.
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.
Change it to Check boxes / radio buttons and save.
Since the allowed values are 4, the contact form will show checkboxes, not radio buttons.
-
1You sure are thorough! Thank you very much for such a detailed answer on such a simple question, it worked perfectly. Apr 11, 2016 at 15:22