Magento:在产品页面中添加自定义联系表单

时间:2014-05-13 15:51:31

标签: magento product contact contact-form

我在模板中使用自定义联系表单创建了一个phtml(是一个包含更多字段的原始联系表单)。在我的网站的产品页面我有一个stati块,在这个块我连接了phtml。联系表单在产品页面中正确查看,但发送电子邮件的提交按钮在购物车中添加了产品(替换按钮“添加到购物车”的操作)。 我们对这个问题有所了解吗?感谢

静态块中的

代码:

 {{block type="core/template" name="contactForm" form_action="/contacts/index/post/" template="catalog/product/productform.phtml"}}

phtml文件:

     <form action="<?php echo $this->getFormAction(); ?>" id="contactForm" method="post"         name="contact_form">
            <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="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>
            </li>
            <li>
                <label for="subject"><?php echo Mage::helper('contacts')->__('Subject') ?> <span class="required">*</span></label>
                <div class="input-box"><input name="subject" id="subject" title="<?php echo Mage::helper('contacts')->__('Subject') ?>" value="" class="required-entry input-text" 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') ?>" 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>

2 个答案:

答案 0 :(得分:3)

我面临同样的问题。 第一组改变形式

的动作
<form action="<?php echo $this->getUrl('contacts/index/post'); ?>"

第二步:将您的static block from inside of add cart form in view.phtml(catalog/product/view)移至添加到购物车表单之外

........
   <?php endif;?>
    </form>
/* you static block */
call here static block

答案 1 :(得分:0)

尝试替换这样的表单操作:

 <form action="<?php echo $this->getUrl('contacts/index/post'); ?>" id="contactForm" method="post" name="contact_form">