0

I called contact form in my .phmtl page using this code:

<?php include ($block->getTemplateFile('Magento_Contact::form.phtml')) ?>

The problem is when I click on submit, there's no success message and we don't receive the mail by consequence.

PS:when I try mywebsite.com/contact it works correctly

6
  • when I try mywebsite.com/contact it works correctly Jun 24, 2019 at 16:25
  • what do you mean exactly please! Jun 24, 2019 at 16:53
  • Hey, check the form action @Nouarizineb Jun 24, 2019 at 16:54
  • <form class="form contact" action="<?php echo $block->getFormAction(); ?>" id="contact-form" method="post" data-hasrequired="<?php /* @escapeNotVerified / echo __(' Required Fields') ?>" data-mage-init='{"validation":{}}'> Jun 24, 2019 at 16:57
  • <?php echo $block->getFormAction();die; ?> and check before form Jun 24, 2019 at 17:01

2 Answers 2

1

Please can U try this way to call form.phtml in your phtml file.

<?php echo $this->getLayout()->createBlock("Magento\Contact\Block\ContactForm")->setTemplate("Magento_Contact::form.phtml")->toHtml(); ?>

hope this helpful

2
1

Use Below code direct into phtml file

<?php echo $this->getLayout()->createBlock("Magento\Framework\View\Element\Template")->setTemplate("Magento_Contact::form.phtml")->toHtml(); ?>
2
  • Thank you! it works perfectly Jun 25, 2019 at 9:04
  • Thank you @Nouarizineb .
    – Shorabh
    Jun 25, 2019 at 9:42

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.