Magento – override contacts form in magento

contact-usmagento-1.9

I am using magento 1.9.I have added a cms page named visit and it displays a form
which is given below

app\design\frontend\default\theme\template\sitevisit\form.phtml

<form action="<?php echo Mage::getUrl('contacts/index/new'); ?>" id="contactForm" method="post">
    <div class="fieldset">

        <ul class="form-list">
            <li class="fields">
                <div class="field">
                    <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->escapeHtml($this->helper('contacts')->getUserName()) ?>" class="input-text required-entry" type="text" />
                    </div>
                </div>
                <div class="field">
                    <label for="name" class="required"><?php echo Mage::helper('contacts')->__('Company') ?></label>
                    <div class="input-box">
                        <input name="company" id="company" title="<?php echo Mage::helper('contacts')->__('Company') ?>" value="<?php echo $this->escapeHtml($this->helper('contacts')->getUserName()) ?>" class="input-text" type="text" />
                    </div>
                </div>
                <div class="field" style="margin-top: 50px;margin-left: 1px">
                    <label for="name" class="required"><em>*</em><?php echo Mage::helper('contacts')->__('Postcode') ?></label>
                    <div class="input-box">
                        <input name="postcode" id="postcode" title="<?php echo Mage::helper('contacts')->__('Postcode') ?>" value="<?php echo $this->escapeHtml($this->helper('contacts')->getUserName()) ?>" class="input-text required-entry" type="text" />
                    </div>
                </div>
                <div class="field" style="margin-top: -43px;margin-left: 425px">
                    <label for="name" class="required"><em>*</em><?php echo Mage::helper('contacts')->__('Preferred Visit Date ') ?></label>
                    <div class="input-box">
                        <input name="v_date" id="v_date" title="<?php echo Mage::helper('contacts')->__('Preferred Visit Date') ?>" value="<?php echo $this->escapeHtml($this->helper('contacts')->getUserName()) ?>" class="input-text required-entry" type="text" />
                    </div>
                </div>
                <div class="field" style="margin-top:50px;margin-left: 0px">
                    <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->escapeHtml($this->helper('contacts')->getUserEmail()) ?>" class="input-text required-entry validate-email" type="text" />
                    </div>
                </div>
             <div class="field" style="margin-top: -43px;margin-left: 425px">
                <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" type="text" />
                </div>
             </div>
            </li>
        </ul>
    </div>
    <div class="buttons-set" style="margin-left: 279px;margin-top: 278px;">
        <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>

this is copied from contacts form and have changed some fields

On submission of the form the details should be sent via email to mytest1@gmail.com.i want to override the core contacts methods. In the site contats form is also used. I want to use both visit and contactus cms pages

Best Answer

It would be better to create new controller (extends Mage_Contacts_IndexController) for posting sitevisit form. This way you will use both old controller for contactus form and new controller for visit form.

Related Topic