Magento contact form in CMS page

The question:

I’m new in magento and I wonder how to create a form in a CMS page and receive the information by email.

I did some research on the internet but I did not find explicit answers.

The Solutions:

Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.

Method 1

First you login Magento admin -> CMS -> Pages

Select your page and input your HTML code as you normally would on any other information you include the page, then select Content tab and add it.

The below lines to add your cms -> page:

{{block type="core/template" name="contactForm" form_action="{{store direct_url='contacts'}}/index/post" template="contacts/form.phtml"}}

Method 2

@mbalparda answer is right, but it partially answer the question. In short, it gives you a perfect hint on how you can include a contact-form block inside cms page. But what about adding a custom form in CMS Page? For this, you can refer below answer.

Step 1 : Create a form

First, you need to create a form that you need to include in CMS Pages. In its simplest form, you should define a new form template for this.

File : appdesignfrontend[package][theme]templatecustomyourform.phtml

<form action="some/action/" name="form-name" id="form-id" >
   <!-- form inputs come here -->

Step 2 : Include Your Custom Form in CMS Page

Go to the CMS Page content section and add below content.

 {{block type="core/template" template="custom/yourform.phtml"}}

We are taking the advantage of block-directives here. You can insert any block in CMS page like this. This will use your custom form template and render its content inside CMS Page.

Method 3

Above answer is right but there are some suggestion for this case.

1.Change form action post url:

Change the action form /contacts/index/post to custom url like /contacts/index/custompost.Because of after form submitting.Custom will redirect to contacts/index/index instead of custom cms page because of code at postAction function of Mage_Contacts_IndexController ($this->_redirect('*/*/');).

So,you need to override Mage_Contacts Indexcontroller and will add a new action custompostAction .

Copy all code of postAction function to custompostAction and just change



Call form block from Design tab:

Instead call of form from Content,call the code at Design tab(Layout Update XML)

<reference name="content">
  <block  type="core/template" name="CmscontactForm" form_action="/contacts/index/custompost"/ >

Method 4


{{block type="core/template" name="contactForm" form_action="/contacts/index/post" template="contacts/form.phtml"}}

in any CMS page. See this page for some more info.

Method 5

  1. First login in your magento admin
  2. Go to your CMS> Manage Pages interface
  3. Once there, input your HTML as you normally would on any other page
  4. Once you are happy with HTML part, add this lines:

{{block type=”core/template” name=”contactForm” form_action=”{{store
direct_url=”contacts”}}/index/post” template=”contacts/form.phtml”}}

Let me know if you have any query

Method 6

For what it’s worth – I’m using Magento 2 and the answers here are for Magento 1.x.

This is the shortcode syntax that worked for me in Magento 2:

{{block class="MagentoFrameworkViewElementTemplate" name="contactForm" form_action="/contacts/index/post" template="Magento_Contact::form.phtml"}}

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Comment