Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Custom contact form
 
mrmoon
Jr. Member
 
Total Posts:  19
Joined:  2011-03-26
 

Hello dear Magento users.

I try customized contact form, but i cant see why it don`t want work.
This code dont want sent any info to my mail box wink
Maybe somebody see some wrong idea on code, etc..

Here you go:

<div class="page-title">
    <
h1><?php echo Mage::helper('contacts')->__('Didn`t find your product? Tell us!'?></h1>
</
div>
<
div id="messages_product_view"><?php echo $this->getMessagesBlock()->getGroupedHtml() ?></div>
<
div id="contact_us">
    <
form action="<?php echo $this->getFormAction(); ?>" id="contactForm" method="post">
        <
div class="fieldset">
            <
h2 class="legend"><?php echo Mage::helper('contacts')->__('Contact Information'?></h2>
            <
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->htmlEscape($this->helper('contacts')->getUserName()) ?>" class="input-text required-entry" type="text" />
                        </
div>
                    </
div>
                    <
div class="field">
                        <
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" type="text" />
                        </
div>
                    </
div>
                </
li>
                <
li>
                    <
label for="printer_brand" class="required"><em>*</em><?php echo Mage::helper('contacts')->__('Printer brand'?></label>
                    <
div class="input-box">
                        <
input name="printer_brand" id="printer_brand" title="<?php echo Mage::helper('contacts')->__('Printer brand') ?>" value="" class="required-entry input-text" type="text" />
                    </
div>
                </
li>
                <
li>
                    <
label for="printer_model" class="required"><em>*</em><?php echo Mage::helper('contacts')->__('Printer model'?></label>
                    <
div class="input-box">
                        <
input name="printer_model" id="printer_model" title="<?php echo Mage::helper('contacts')->__('Printer model') ?>" value="" class="required-entry input-text" type="text" />
                    </
div>
                </
li>
                <
li>
                    <
label for="message" class="required"><em>*</em><?php echo Mage::helper('contacts')->__('Cartridge code'?></label>
                    <
div class="input-box">
                        <
input name="message" id="message" title="<?php echo Mage::helper('contacts')->__('Cartridge code') ?>" class="required-entry input-text" type="text"></input>
                    </
div>
                </
li>
            </
ul>
        </
div>
        <
div class="buttons-set">
            <
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>
</
div>
<
script type="text/javascript">
//<![CDATA[
    
var contactForm = new VarienForm('contactForm'true);
//]]>
</script>

Best regards,
mrmoon

 
Magento Community Magento Community
Magento Community
Magento Community
 
Sunovisio
Sr. Member
 
Avatar
Total Posts:  94
Joined:  2012-04-12
Ho Chi Minh
 

Hi mrmoon,

Currently you added the fields to your form but not to your template. So edit the file: contact_form.phtml (or load it in your transactional email section in admin). The content should be like this:

<!--@subject Contact Form@-->
<!--@
vars
{
"var data.name":"Sender Name",
"var data.email":"Sender Email",
"var data.telephone":"Sender Telephone",
"var data.comment":"Comment"}
@-->
Name{{var data.name}}
E
-mail{{var data.email}}
Telephone
{{var data.telephone}}

Comment
{{var data.comment}}

Adding to this file

Printer Brand{{var data.printer_brand}}
Printer Model
{{var data.printer_model}}
should do the stuff.

As well I wrote an article on how to do this in my blog http://loicfarge.com/how-to-add-custom-field-in-contact-form/. Don’t hesitate to have a look at it for further information.

Hope my answer will help you.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top