7

Hi I am trying to use Default contact form in my static block or custom cms page. for that I am using this code. but not getting any result.

{{block class="Magento\Framework\View\Element\Template" name="contactForm" form_action="/contacts/index/post" template="contacts/form.phtml"}}

4 Answers 4

11

Call your contact form block with template file in the cms pages.

Try below code :

{{block class="Magento\Contact\Block\ContactForm" name="contactForm" template="Magento_Contact::form.phtml"}}
7
  • Can I use this in custom statick block
    – sanjay
    May 8, 2017 at 9:55
  • Yes you can use it May 8, 2017 at 9:56
  • this is not working in custom static block
    – sanjay
    May 8, 2017 at 9:58
  • When I include this in custom Block- and open this , my page does not load
    – sanjay
    May 8, 2017 at 12:34
  • @sanjay okay have you switched the WYSIWYG editor and puted this code as an plain text ? also can you please check you have selected all store view option from store view dropdown ? May 8, 2017 at 12:41
3

There are two mistakes:

1) use Magento\Contact\Block\ContactForm instead of Magento\Framework\View\Element\Template.

2) Define your module in template Magento_Contact::form.phtml.

{{block class="Magento\Contact\Block\ContactForm" name="contactForm" template="Magento_Contact::form.phtml"}}
0

Your block class is Incorrect, because Magento\Framework\View\Element\Template is default block of Magento 2 and for contact us you should write, Magento\Contact\Block\ContactForm, like this

{{block class="Magento\Contact\Block\ContactForm" name="contactForm" template="Magento_Contact::form.phtml"}}
0

You need to use just below code

{{block class="Magento\Contact\Block\ContactForm" name="contactForm" template="Magento_Contact::form.phtml"}}
3
  • SH patel, can i used this code in my custom static block this is not working right now
    – sanjay
    May 8, 2017 at 10:03
  • Yes you can use it in custom static block. May 8, 2017 at 10:15
  • But when I use this @ it's does not showing any thing
    – sanjay
    May 8, 2017 at 11:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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