This time we want to show you how to modify the fields of the contact form provided by Magento. As it is known, it has basic contact fields: Name, email, phone, country and comment, which are essential and very useful. But if we are in the situation of requiring additional information, it is necessary to make some modifications.

Let’s imagine that we have a housewares store and we want to know what are the user’s preferences regarding the products we provide. To do this, go to the file form.phtml of the folder Contacts of our theme by following the path: dev/app/design/frontend/default/su-tema/template/contacts/form.phtml.

Once there, we add the corresponding field. For this example we are going to add the following to the form “Preferencias”, and we will do it as follows:

<div class="field"><label class="required" for="preferences"> <em>*</em><!--?php echo Mage::helper('contacts')->__('Preferences') ?--> </label>
<div class="input-box"><select id="preferences" class="required-entry" name="preferences">
<option selected="selected" value=" "><!--?php echo Mage::helper('contacts')->__('Please select...') ?--></option>
<option value="lighting"><!--?php echo Mage::helper('contacts')->__('Lighting') ?--></option>
<option value="gardening"><!--?php echo Mage::helper('contacts')->__('Gardening') ?--></option>
<option value="lingerie"><!--?php echo Mage::helper('contacts')->__('Lingerie') ?--></option>
<option value="furniture"><!--?php echo Mage::helper('contacts')->__('Furniture') ?--></option>
<option value="others"><!--?php echo Mage::helper('contacts')->__('Others') ?--></option>

Note: In this example, the syntax: Mage::helper(‘contacts’)->__(‘Please select…’) is used if the store supports multiple languages, and is the way to refer to the word for its subsequent translation in the corresponding .csv file.

After having added the element to the contact form, you need to define the email template with the new field, for this we go to the Magento administration panel following the path: System -> Transactional Emails and click on the button: Add New Template.

After that, in the area called Load Default Template, in the Template field, the Contact Form option is selected.  Going to the Template information area, in the Template Name field, we place the name we want to give to the new template, and in the area called Template Content we add the new field, following the syntax: {{var data.preferences}}.

Magento Custom Form Settings | blog itandfeel

After having defined the new template we must assign it, to do this within the Magento administration panel, we go to: System -> General -> Contacts, and in the Email Options area, specifically in the Email Template field, we select the new template created. Finally we click on the Save Config button.

And that’s it, in this way we have already defined a personalized contact form, together with its email template for sending additional information.