I am facing CSS issues when trying to customize the design of the contact form through the Contact module. I am unable to achieve this using the form alter hook, possibly due to the lack of machine names for input fields. Is there any alternative approach you could suggest?
f you are facing difficulties customizing the design of the contact form using the form alter hook. Here are a few suggestions:
-
Instead of relying on machine names, you can use specific CSS selectors to target the form elements you want to style. You can inspect the HTML structure of the form using browser developer tools and identify unique IDs or class names associated with the form elements. Then, you can use these identifiers in your CSS to style the elements accordingly.
-
If the form elements do not have specific classes, you can use JavaScript to add classes dynamically based on the form structure.
-
You can create a custom template for the contact form by overriding the original template file (
contact-form.html.twig
) from the Contact module to your theme’s templates directory and modify it according to your needs. This allows you to have full control over the HTML structure and class names.