Magento – Add additional fields to the Contact Form

If you need to add additional fields to Magento’s default contact form, read on! First open the form.phtml file located in your /magento_root/app/design/frontend/YOUR_INTERFACE/YOUR_THEME/template/contacts/form.phtml. So, we are going to add a subject field to this contact form so that customers tell us the subject of their email. Open the file for editing in your favorite editor.

Find this section in the file below (this should be around line 39):

We are going to add another field above this one for the subject of the email. Copy and paste this code above the block of code (name field) referenced above.

As far as Magento is concerned, it doesn’t care what fields we add to this form. It is written in such a way that it accepts all of the field posted for processing and send that out to the transactional e-mail form that you create. Now, go to System->Transactional E-mails in the Magento Admin section. Click “Add New Template” and from the “Template” dropdown box select “Contact Form” then “Load Template”. Under template content you will see:

Add your new field before Name: {{var}} so that now it should looks like this:

Enter a new name under “Template Name” to save your new Template and click on “Save Template”. Now we need to tell Magento to use this new template for the Contact form. Go to System->Configuration and select “Contacts”. Under “Email Options”, select your new template under the “Email Template” dropdown box. Click on “Save Config”.

That’s it! πŸ˜‰

35 thoughts on “Magento – Add additional fields to the Contact Form”

  1. Thank you for this nugget of delicious code. Do I understand correctly that the “input-text” class triggers text validation and the “required-entry” class tests for null entries? If so, its just another reason why Magento gets me excited.

  2. how about if we want to hide a field as per requirement for one case and show for some other???

    like telephone number

    Telephone: {{var data.telephone}}

    do we need to check it by {{depend data.telephone}} condition….{{/depend}}

    i tried it but for both mails its showing up… help πŸ™‚

  3. Spectacular! Absolutely awesome work – this plugin has been extremely helpful to me and I’m so happy to see the improvements. Keep up the good work!

  4. I would like to thank you for the efforts you have made in composing this article. thanks for sharing the great information.

  5. Hi,

    Have a lot of spam through my contactform at website..

    Can i add a field, where user need to make a word verification (ex. from a image), or how can i fix??



  6. Hi, I have a question, how can I add select field to the contact form. Actually the select field shows up correctly, but the entered value doesn’t go over. Any idea? 23

  7. Great post. I found what I was looking for. Do you mind if I post this on my website and give you credit? If not, it’s ok.

Leave a Reply

Your email address will not be published. Required fields are marked *