0

Could anyone help? i want to use contact form in footer without redirects to different page after submitting the form.

Everything working fine but form redirects to different page after submitting the form. I want successful and error messages under the form.

i m using below code

{{block class="Magento\Contact\Block\ContactForm" name="contactForm" template="Magento_Contact::form.phtml"}}
4
  • Please share your contact form details to better understand issue. May 3, 2017 at 10:45
  • Is It redirect to yourDomain/contact ? May 3, 2017 at 10:48
  • please show getFormAction() function from block file. May 3, 2017 at 10:53
  • Hi rakesh thanks for your reply Please find below code.
    – user51556
    May 3, 2017 at 11:07

1 Answer 1

0
<?php
/**
 * Copyright © 2015 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */

// @codingStandardsIgnoreFile
$ves = $this->helper('Ves\Themesettings\Helper\Theme');
$vesData = $this->helper('Ves\Themesettings\Helper\Data');

$show_contactform = $ves->getContactPageCfg('contactform/show_contactform');

$show_googlemap = $ves->getContactPageCfg('googlemap/show_googlemap');
$map_api = $ves->getContactPageCfg('googlemap/map_api');
$map_api = $map_api?'key='.$map_api.'&amp;':"key=AIzaSyALraGXlzRqFlAOb-tYLhUi6o6Cq9qN4KA&amp;";
$location_lng = $ves->getContactPageCfg('googlemap/location_lng');
$location_lat = $ves->getContactPageCfg('googlemap/location_lat');
$address = $ves->getContactPageCfg('googlemap/address');
$telephone = $ves->getContactPageCfg('googlemap/telephone');
$fax = $ves->getContactPageCfg('googlemap/fax');
$enable_contactus = $ves->getContactPageCfg('googlemap/enable_contactus');
$enable_contactform = $ves->getContactPageCfg('googlemap/enable_contactform');
$custom_html = $ves->getContactPageCfg('googlemap/custom_html');
$map_width = $ves->getContactPageCfg('googlemap/map_width');
$map_height = $ves->getContactPageCfg('googlemap/map_height');
$map_zoom = (int)$ves->getContactPageCfg('googlemap/map_zoom');

$marker_content = $ves->getContactPageCfg('googlemap/marker_content');
if($marker_content!=''){
    $marker_content = $vesData->filter($marker_content);
}

$marker_content_staticblock = $ves->getContactPageCfg('googlemap/marker_content_staticblock');
$marker_content_width = $ves->getContactPageCfg('googlemap/marker_content_width');
$marker_content_height = $ves->getContactPageCfg('googlemap/marker_content_height');
$marker_content_position = $ves->getContactPageCfg('googlemap/marker_content_position');
?>
<div class="ves-contact">
    <div class="block">     
                    <?php if($show_contactform){ ?>
                    <div class="col-lg-8 col-md-8 col-sm-12 col-xs-12">
                        <div class="block form contact">
                            <div class="block-title"><strong><?php /* @escapeNotVerified */ echo __('Write Us') ?></strong> </div>
                                <div class="block-content">
                                <form action="<?php /* @escapeNotVerified */ echo $block->getFormAction(); ?>"
                                id="contact-form"
                                method="post"
                                data-hasrequired="<?php /* @escapeNotVerified */ echo __('* Required Fields') ?>"
                                data-mage-init='{"validation":{}}'>
                                    <fieldset class="fieldset">
                                        <div class="field note no-label"><?php /* @escapeNotVerified */ echo __('Jot us a note and we’ll get back to you as quickly as possible.') ?></div>
                                        <div class="field name required">                                            
                                            <div class="control">
                                                <input name="name" id="name" title="<?php /* @escapeNotVerified */ echo __('Name') ?>" value="<?php echo $block->escapeHtml($this->helper('Magento\Contact\Helper\Data')->getUserName()) ?>" placeholder="Name" class="input-text" type="text" data-validate="{required:true}"/>
                                            </div>
                                        </div>
                                        <div class="field email required">
                                            <div class="control">
                                                <input name="email" id="email" title="<?php /* @escapeNotVerified */ echo __('Email') ?>" value="<?php echo $block->escapeHtml($this->helper('Magento\Contact\Helper\Data')->getUserEmail()) ?>" placeholder="Email" class="input-text" type="email" data-validate="{required:true, 'validate-email':true}"/>
                                            </div>
                                        </div>                                       
                                        <div class="field comment required">                                            
                                            <div class="control">
                                                <textarea name="comment" id="comment" title="<?php /* @escapeNotVerified */ echo __('What’s on your mind?') ?>" placeholder="What’s on your mind?" class="input-text" cols="5" rows="3" data-validate="{required:true}"></textarea>
                                            </div>
                                        </div>
                                        <?php echo $block->getChildHtml('form.additional.info'); ?>
                                    </fieldset>
                                    <div class="actions">
                                        <input type="hidden" name="hideit" id="hideit" value="" />
                                        <button type="submit" title="<?php /* @escapeNotVerified */ echo __('Submit') ?>" class="action submit primary">
                                            <span><?php /* @escapeNotVerified */ echo __('Submit') ?></span>
                                        </button>
                                    </div>
                                </form>
                            </div>  
                        </div>
                    </div>
                    <?php } ?>
            </div>
        </div>

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.