Skip to content

unable To Add Contact Form To CMS Page In Magento 2?

I added below info but contact foam not showing

app/design/frontend/company/name_theme/Magento_Contact/templates/form.phtml

Then, insert the contact form to the CMS page
{{block type=’core/template’ name=’contact-form’ template=’contacts/form.phtml’}}

Form.phtml code:

getViewModel();
?>
escapeUrl($block->getFormAction()) ?>”
id=”contact-form”
method=”post”
data-hasrequired=”escapeHtmlAttr(__(‘* Required Fields’)) ?>”
data-mage-init='{“validation”:{}}’>

escapeHtml(__(‘Write Us’)) ?>

escapeHtml(__(‘Jot us a note and we’ll get back to you as quickly as possible.’)) ?>

escapeHtml(__(‘Name’)) ?>

escapeHtmlAttr(__(‘Name’)) ?>”
value=”escapeHtmlAttr($viewModel->getUserName()) ?>”
class=”input-text”
type=”text”
data-validate=”{required:true}”/>

escapeHtml(__(‘Email’)) ?>

escapeHtmlAttr(__(‘Email’)) ?>”
value=”escapeHtmlAttr($viewModel->getUserEmail()) ?>”
class=”input-text”
type=”email”
data-validate=”{required:true, ‘validate-email’:true}”/>

escapeHtml(__(‘Phone Number’)) ?>

escapeHtmlAttr(__(‘Phone Number’)) ?>”
value=”escapeHtmlAttr($viewModel->getUserTelephone()) ?>”
class=”input-text”
type=”tel” />

escapeHtml(__(‘What’s on your mind?’)) ?>

escapeHtmlAttr(__(‘What’s on your mind?’)) ?>”
class=”input-text”
cols=”5″
rows=”3″
data-validate=”{required:true}”
>escapeHtml($viewModel->getUserComment()) ?>

getChildHtml(‘form.additional.info’) ?>

escapeHtmlAttr(__(‘Submit’)) ?>” class=”action submit primary”>
escapeHtml(__(‘Submit’)) ?>

{
“*”: {
“Magento_Customer/js/block-submit-on-send”: {
“formId”: “contact-form”
}
}
}