Create Your custom Form with magento validation In:
app/design/frontend/Your_theme/default/template/custompage/application_form.phtml

<div class="application-form-wraper">
    <h2 class="title"><?php echo $this->__('Application Form') ?></h2>
    <form action="<?php echo $this->getBaseUrl()?>contacts/index/applicationform" id="contactForm" method="post">
        <table border="1">
            <tbody>
                <tr>
                    <td><label for="name"><?php echo $this->__('Name:') ?></label></td>
                    <td><input class="input-text required-entry" type="text" size="27" id="name" name="name" value=""></td>
                </tr>
                <tr>
                    <td><label for="address"><?php echo $this->__('Address:') ?></label></td>
                    <td><textarea class="input-text required-entry" id="address" name="address" cols="27" rows="5"></textarea></td>
                </tr>
                <tr>
                    <td><label for="telephone"><?php echo $this->__('Tel:') ?></label></td>
                    <td><input class="input-text required-entry" type="text" size="27" id="telephone" name="telephone" value=""></td>
                </tr>
                <tr>
                    <td><label for="mobile"><?php echo $this->__('Mobile:') ?></label></td>
                    <td><input class="input-text required-entry" type="text" size="27" id="mobile" name="mobile" value=""></td>
                </tr>
                <tr>
                    <td><label for="email"><?php echo $this->__('Email:') ?></label></td>
                    <td><input class="input-text required-entry validate-email" type="text" size="27" id="email" name="email" value=""></td>
                </tr>
                <tr>
                    <td><label for="dob"><?php echo $this->__('Date of Birth:') ?></label></td>
                    <td><input class="input-text required-entry" type="text" size="27" id="dob" name="dob" value=""></td>
                </tr>
                <tr>
                    <td><label for="pps"><?php echo $this->__('PPS / Nat Ins Number:') ?></label></td>
                    <td><input class="input-text required-entry" type="text" size="27" id="pps" name="pps" value=""></td>
                </tr>
                <tr>
                    <td><label for="own-transport"><?php echo $this->__('Own Transport:') ?></label></td>
                    <td>
                        <select id="own-transport" name="own-transport">
                            <option value="<?php echo $this->__('Yes') ?>"><?php echo $this->__('Yes') ?></option>
                            <option value="<?php echo $this->__('No') ?>"><?php echo $this->__('No') ?></option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td><label for="driving-licence"><?php echo $this->__('Driving Licence:') ?></label></td>
                    <td>
                        <select id="driving-licence" name="driving-licence">
                            <option value="<?php echo $this->__('Full') ?>"><?php echo $this->__('Full') ?></option>
                            <option value="<?php echo $this->__('Prov.') ?>"><?php echo $this->__('Prov.') ?></option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td><label for="availability"><?php echo $this->__('Availability:') ?></label></td>
                    <td>
                        <select id="availability" name="availability">
                            <option value="<?php echo $this->__('Part-time') ?>"><?php echo $this->__('Part-time') ?></option>
                            <option value="<?php echo $this->__('Full-time') ?>"><?php echo $this->__('Full-time') ?></option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td colspan="2"><strong><?php echo $this->__('Experience (Please tick)') ?></strong>
                        <table border="1">
                            <tbody>
                                <tr>
                                    <td><label for="milking"><?php echo $this->__('Milking:') ?></label></td>
                                    <td><input type="checkbox" id="milking" name="milking" value="<?php echo $this->__('yes') ?>"></td>
                                    <td><label for="sheep"><?php echo $this->__('Sheep:') ?></label></td>
                                    <td><input type="checkbox" id="sheep" name="sheep" value="<?php echo $this->__('yes:') ?>"></td>
                                </tr>
                                <tr>
                                    <td><label for="fencing"><?php echo $this->__('Fencing:') ?></label></td>
                                    <td><input type="checkbox" id="fencing" name="fencing" value="<?php echo $this->__('yes:') ?>"></td>
                                    <td><label for="pigs"><?php echo $this->__('Pigs:') ?></label></td>
                                    <td><input type="checkbox" id="pigs" name="pigs" value="<?php echo $this->__('yes:') ?>"></td>
                                </tr>
                                <tr>
                                    <td><label for="machinery"><?php echo $this->__('Machinery:') ?></label></td>
                                    <td><input type="checkbox" id="machinery" name="machinery" value="<?php echo $this->__('yes:') ?>"></td>
                                    <td><label for="other-pls-select"><?php echo $this->__('Other (Please State):') ?></label></td>
                                    <td><textarea id="other-pls-select" name="other-pls-select" cols="25" rows="5"> </textarea></td>
                                </tr>
                            </tbody>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td><label for="aspect"><?php echo $this->__('Is there any aspect of health that would restrict or limit your employment - if yes give details:') ?></label></td>
                    <td><textarea class="required-entry" id="aspect" name="aspect" cols="25" rows="5"></textarea></td>
                </tr>
                <tr>
                    <td><label for="referees"><?php echo $this->__('Referees:') ?></label></td>
                    <td><textarea class="required-entry" id="referees" name="referees" cols="25" rows="5"></textarea></td>
                </tr>
                <tr>
                    <td><label for="comments"><?php echo $this->__('Comments:') ?></label></td>
                    <td><textarea class="required-entry" id="comments" name="comments" cols="25" rows="5"></textarea></td>
                </tr>
                <tr>
                    <td><input type="submit" value="Submit" name="submit" class="button"></td>
                    <td><input type="reset" value="Reset" name="reset" class="button"></td>
                </tr>
            </tbody>
        </table>
    </form>
    <script type="text/javascript">
        //<!&#91;CDATA&#91;
            var contactForm = new VarienForm('contactForm', true);
        //&#93;&#93;>
    </script>
</div>

Create A small extension with following files:

app/etc/modules/Sushant_Contacts.xml


<?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <Sushant_Contacts>
            <active>true</active>
            <codePool>local</codePool>
        </Sushant_Contacts>
    </modules>
</config>

app/code/local/Sushant/Contacts/controllers/IndexController.php

<?php
require_once 'Mage/Contacts/controllers/IndexController.php';
class Sushant_Contacts_IndexController extends Mage_Contacts_IndexController
{
    
    const XML_PATH_EMAIL_RECIPIENT  = 'contacts/email/recipient_email';
    const XML_PATH_EMAIL_SENDER     = 'contacts/email/sender_email_identity';
    const XML_PATH_EMAIL_TEMPLATE   = 'contacts/email/email_template';
    const XML_PATH_ENABLED          = 'contacts/contacts/enabled';

    public function preDispatch()
    {
        parent::preDispatch();

        if( !Mage::getStoreConfigFlag(self::XML_PATH_ENABLED) ) {
            $this->norouteAction();
        }
    }

    public function indexAction()
    {
        $this->loadLayout();
        $this->getLayout()->getBlock('contactForm')
            ->setFormAction( Mage::getUrl('*/*/post') );

        $this->_initLayoutMessages('customer/session');
        $this->_initLayoutMessages('catalog/session');
        $this->renderLayout();
    }
    /********************************Custom from start**************************************************/
    public function applicationformAction(){
        $post = $this->getRequest()->getPost();
				if($post){
							
						try{
								
							$name=$post['name'];
							$address=$post['address'];
							
							$tel=$post['telephone'];
							$mobile=$post['mobile'];
							$email=$post['email'];
							$dob=$post['dob'];
							$pss=$post['pps'];
							$transport=$post['own-transport'];
							$drive=$post['driving-licence'];
							$available=$post['availability'];
							$milking=$post['milking'];
							$ship=$post['sheep'];
							$fencing=$post['fencing'];
							$pigs=$post['pigs'];
							$mechinary=$post['machinery'];
							$other=$post['other-pls-select'];
							$aspect=$post['aspect'];
							$referees=$post['referees'];
							$comment=$post['comments'];
							
							
									// set the Transactional Email Template's ID that you've created...
							 $templateId = 3;
					 
							 // Set sender information
							 $senderName = $name;
							 $senderEmail =$email;
							 $sender = array('name' => $senderName,
													 'email' => $senderEmail);
					 
							 // Set recepient information
							 $recepientEmail = 'cmoffitt@donegalfrs.com';
							 $recepientName = 'farmrelief';        
					 
							 // Get Store ID
							 $storeId = Mage::app()->getStore()->getId();
					 
							 // Set variables that can be used in email template. To get this variable write like {{var customerEmail}} in transactional Email.
							 $vars = array('name' => $name,
									'address' => $address,
								        'telephone' => $tel,
									'mobile' => $mobile,
									'your-email' => $email,
									'dob' => $dob,
									'pps' => $pss,
									'own-transport' => $transport,
									'driving-licence' => $drive,
									'availability' => $available,
									'sheep' => $ship,
									'milking' => $milking,
									'fencing' => $fencing,
									'pigs' => $pigs,
									'machinery' => $mechinary,
									'other-pls-select'=>$other,
									'aspect'=>$aspect,
									'referees'=>$referees,
									'comments'=>$comment
					 
														);
					 
							 $translate  = Mage::getSingleton('core/translate');
					 
							 // Send Transactional Email
							 Mage::getModel('core/email_template')
									 ->addBcc('info@donegalfrs.com')      // You can remove it if you don't need to send bcc 
									 ->sendTransactional($templateId, $sender, $recepientEmail, $recepientName, $vars, $storeId);
						 Mage::getSingleton('customer/session')->addSuccess(Mage::helper('contacts')->__('Thank you for contacting us. Your message has been received. We will get back to you shortly.'));
						 $translate->setTranslateInline(true);
										$this->_redirectReferer();
										return;
						}
						catch (Exception $e){
								$translate->setTranslateInline(true);
								Mage::getSingleton('customer/session')->addError(Mage::helper('contacts')->__('Unable to submit your request. Please, try again later'));
								$this->_redirectReferer();
								return;
						}
						
				}
    }
       /********************************Custom from End**************************************************/
        
    
}

app/code/local/Sushant/Contacts/etc/config.xml:

<?xml version="1.0"?>
<config>
    <modules>
        <Sushant_Contacts>
            <version>0.0.1</version>
        </Sushant_Contacts>
    </modules>
    <frontend>
        <routers>
            <contacts>
                <use>standard</use>
                <args>
                    <module before="Mage_Contacts">Sushant_Contacts</module>
                </args>
            </contacts>
        </routers>
    </frontend>
</config>


0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *