Tuesday, 14 August 2012

How to add a extra field “Contact Us” form in magento

Step One: Modify the (interface)/(theme)/template/contacts/form.phtml file.
Say we would like to add a field called ‘Test’ in between e-mail and telephone on the default field.


  1. class
="input-box">
  •                    
  • ="email">echo $this->__('Email') ?> class="required">*
  •                     <input name="email" id="email" title="__('Email') ?>" value="htmlEscape($this->helper('contacts')->getUserEmail()) ?>" class="required-entry input-text validate-email" type="text"/>
  •                
  •                
    class
  • ="clear">
  •                
    class
  • ="input-box">
  •                    
  • ="telephone">echo $this->__('Telephone') ?>
  •                     <input name="telephone" id="telephone" title="__('Telephone') ?>" value="" class="input-text" type="text"/>
  •                
  • Here is the new field

    1. class
    ="input-box">
  •                    
  • ="email">echo $this->__('Email') ?> class="required">*
  •                     <input name="email" id="email" title="__('Email') ?>" value="htmlEscape($this->helper('contacts')->getUserEmail()) ?>" class="required-entry input-text validate-email" type="text"/>
  •                
  •                
    class
  • ="clear">
  •                
    class
  • ="input-box">
  •                    
  • ="test">echo $this->__('Test') ?>
  •                     <input name="test" id="test" title="__('Test') ?>" value="" class="input-text" type="text"/>
  •                
  •                
    class
  • ="input-box">
  •                    
  • ="telephone">echo $this->__('Telephone') ?>
  •                     <input name="telephone" id="telephone" title="__('Telephone') ?>" value="" class="input-text" type="text"/>
  •                
  • Step Two: Create the new Transactional E-Mail form.
    1) Go to System→Transactional E-mails in the Magento Admin section. 2) Click ‘Add New Template’ 3) From the ‘Template’ dropdown box select ‘Contact Form’ 4) Click ‘Load Template’ 5) Under template content you will see:

    1. Name: {{var data.name}}
    2. E-mail: {{var data.email}}
    3. Telephone: {{var data.telephone}}
    4. Comment: {{var data.comment}}
      Add your new field in between E-mail and Telephone: 


    1. Name: {{var data.name}}
    2. E-mail: {{var data.email}}
    3. Test: {{var data.test}}
    4. Telephone: {{var data.telephone}}
    5. Comment: {{var data.comment}}

    No comments: