6

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.

7

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"}}
| improve this answer | |
  • It seesms that @keyurshah 's answer and this answer are same. If you have further points other than Keyur's, edit your answer and post it. – Rajeev K Tomy May 12 '15 at 5:40
  • I made custom layout page for cms page and in that when i use this code to add contact form it is showing entered code in cms editor not form. Please help me. – Chandresh Sep 11 '15 at 5:10
  • How to add Feedback form to home page as static like snag.gy/eKHyw9.jpg, code : dropbox.com/sh/32zqgejubfllz0h/AACkB_iIh-KJQxtEUikZ8i9Na?dl=0 @East – Gem Oct 1 '18 at 11:10
4

@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 : app\design\frontend\[package]\[theme]\template\custom\yourform.phtml

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

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.

| improve this answer | |
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

   $this->_redirect('*/*/');
      to

      $backUrl=Mage::getUrl().'cmsPageInd';
      $this->getResponse()->setRedirect($backUrl);

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"/ >
</reference>
| improve this answer | |
  • thank you all for your response . its works but i have another matter , the form didn't do anything I want to recover data from my form to my adresse mail – djodev May 12 '15 at 8:09
  • This was hugely helpful and exactly what I was after (namely the custompostAction bit). Thank you once again Amit Bera :) – Jimmery Sep 17 '15 at 8:25
2

Use

<!– CONTACT FORM –>
{{block type="core/template" name="contactForm" form_action="/contacts/index/post" template="contacts/form.phtml"}}
<!– END OF CONTACT FORM –>

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

| improve this answer | |
  • to avoid form_action issue we have to write form_action="{{store direct_url=”contacts”}}/index/post" . correct me if am wrong @mbalparda – Keyur Shah May 12 '15 at 5:22
1
  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

| improve this answer | |
0

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="Magento\Framework\View\Element\Template" name="contactForm" form_action="/contacts/index/post" template="Magento_Contact::form.phtml"}}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.