Question

I have contact us page which includes map, form, and some text. the page url is /contacts_page, but when i submit the form it goes to some different url i.e /contacts/index and this new redirect page shows thank you message and contact form. I want to make the url to redirect on same page after submitting with thank you message near the form or in place of form. below is my form.html code. Can anyone check and help me how to fixed it? I dont understand how to display proper html code here

<div id="messages_product_view"><?php echo $this->getMessagesBlock()->getGroupedHtml() ?></div>
<form action="<?php echo Mage::getUrl('contacts/index/post'); ?>" id="contactForm" method="post">
    <div class="fieldset">
        <h2 class="legend"><?php echo Mage::helper('contacts')->__('Contact Information') ?></h2>
        <ul class="form-list">
            <li>
                <!-- <label for="name" class="required"><em>*</em><?php echo Mage::helper('contacts')->__('Name') ?></label> -->
                <div class="input-box">
                    <input name="name" id="name" title="<?php echo Mage::helper('contacts')->__('Name') ?>" value="<?php echo $this->htmlEscape($this->helper('contacts')->getUserName()) ?>" class="input-text required-entry" placeholder="<?php echo Mage::helper('contacts')->__('Name') ?>" type="text" />
                </div>
            </li>
            <li>
                <!-- <label for="email" class="required"><em>*</em><?php echo Mage::helper('contacts')->__('Email') ?></label> -->
                <div class="input-box">
                    <input name="email" id="email" title="<?php echo Mage::helper('contacts')->__('Email') ?>" value="<?php echo $this->htmlEscape($this->helper('contacts')->getUserEmail()) ?>" class="input-text required-entry validate-email" placeholder="<?php echo Mage::helper('contacts')->__('Email') ?>" type="text" />
                </div>
            </li>
            <li>
                <!-- <label for="telephone"><?php echo Mage::helper('contacts')->__('Telephone') ?></label> -->
                <div class="input-box">
                    <input name="telephone" id="telephone" title="<?php echo Mage::helper('contacts')->__('Telephone') ?>" value="" class="input-text" placeholder="<?php echo Mage::helper('contacts')->__('Telephone') ?>" type="text" />
                </div>
            </li>
            <li class="wide">
                <!-- <label for="comment" class="required"><em>*</em><?php echo Mage::helper('contacts')->__('Comment') ?></label> -->
                <div class="input-box">
                    <textarea name="comment" id="comment" title="<?php echo Mage::helper('contacts')->__('Comment') ?>" placeholder="<?php echo Mage::helper('contacts')->__('Comment') ?>" class="required-entry input-text" cols="5" rows="3"></textarea>
                </div>
            </li>
        </ul>
    </div>
    <div class="buttons-set">
        <!-- <p class="required"><?php echo Mage::helper('contacts')->__('* Required Fields') ?></p> -->
        <input type="text" name="hideit" id="hideit" value="" style="display:none !important;" />
        <button type="submit" title="<?php echo Mage::helper('contacts')->__('Submit') ?>" class="button"><span><span><?php echo Mage::helper('contacts')->__('Submit') ?></span></span></button>
    </div>
</form>
<script type="text/javascript">
//<![CDATA[
    var contactForm = new VarienForm('contactForm', true);
//]]>
</script>
Was it helpful?

Solution

You have to rewrite the contact controller action.

Look at Mage_Contacts_IndexController::postAction() (file app/code/core/Mage/Contacts/controllers/IndexController.php).

You will see $this->_redirect('*/*/') that means contacts/index/index.

So, if you want to redirect to another page you have to rewrite the controller's logic and change its redirect destination.

Here is a link of a tutorial on how to override controllers: http://inchoo.net/magento/overriding-magento-blocks-models-helpers-and-controllers/ .

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top