表单有时提交数据,有时不提交。 Magento 1.9

Form sometimes submitting data, sometimes not. Magento 1.9

我有一个调用表单的页面,从用户那里收到有时提交不正确的报告。不知道为什么。有什么想法吗?

用户一直在各种浏览器中报告此问题,因此追踪起来特别困难。 Chrome, IE, Edge, Safari 等都报错了,但有时也能正常工作

表单应该做的是获取输入的数据,然后将其通过电子邮件发送到特定的电子邮件地址。

Magento 块:

<div class="page-title">
   <h1>Program</h1>
</div>
<img class="textwrap-right" src="{{media url="wysiwyg/cfi_rebate_badge.png"}}" alt="" />
<div class="std">
   <h3 class="ui-helper-clearfix">Sign up below.</h3>
   {{widget type="mailform/widget_form" form_template="contacts/cfi.phtml"}}<br />
</div>

这是我的 contacts/cfi.phtml 模板:

<?php
$directory = Mage::helper('directory');
$customer = Mage::getSingleton('customer/session')->getCustomer();
$customerAddress = $customer->getAddressById( $customer->getDefaultBilling() );
if($customerAddress->getCountryId() != 'US'){
    $customerAddress = Mage::getModel('customer/address');
}
?>
<div id="messages_product_view"><?php echo $this->getMessagesBlock()->getGroupedHtml() ?></div>

<form action="<?php echo $this->getFormAction() ?>" id="contactForm" method="post" class="scaffold-form">
    <div class="fieldset">
        <h2 class="legend"><?php echo Mage::helper('contacts')->__('Contact Information') ?></h2>
        <p class="required"><?php echo Mage::helper('contacts')->__('* Required Fields') ?></p>
        <ul class="form-list">
            <li class="fields">
                <div class="field">
                    <label for="cfirebate:name" class="required"><em>*</em><?php echo Mage::helper('contacts')->__('Name') ?></label>
                    <div class="input-box">
                        <input name="cfirebate[name]" id="cfirebate: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>
                <input type="hidden" name="cfirebate[country]" id="cfirebate:country_id" value="US">
                <div class="field">
                    <label for="cfirebate:address" class="required"><em>*</em><?php echo Mage::helper('contacts')->__('Address') ?></label>
                    <div class="input-box">
                        <input name="cfirebate[address]" id="cfirebate:address" title="<?php echo Mage::helper('contacts')->__('Address') ?>" class="input-text required-entry" type="text" />
                    </div>
                </div>
                <div class="field">
                    <label for="cfirebate:city" class="required"><em>*</em><?php echo Mage::helper('contacts')->__('City') ?></label>
                    <div class="input-box">
                        <input name="cfirebate[city]" id="cfirebate:city" title="<?php echo Mage::helper('contacts')->__('City') ?>" class="input-text required-entry" type="text" />
                    </div>
                </div>
                <div class="field">
                    <div class="field">
                        <label for="cfirebate:region" class="required"><em>*</em><?php echo $this->__('State/Province') ?></label>
                        <div class="input-box">
                            <select id="cfirebate:region_id" name="cfirebate[region_id]" title="<?php echo $this->__('State/Province') ?>" class="validate-select" style="display:none;">
                                <option value="">Please select region, state or province</option>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="field">
                    <label for="cfirebate:postcode" class="required"><em>*</em><?php echo Mage::helper('contacts')->__('Zip') ?></label>
                    <div class="input-box">
                        <input name="cfirebate[postcode]" id="cfirebate:postcode" title="<?php echo Mage::helper('contacts')->__('Zip') ?>" class="input-text required-entry" type="text" />
                    </div>
                </div>
                <div class="field">
                    <label for="cfirebate:email" class="required"><em>*</em><?php echo Mage::helper('contacts')->__('Email') ?></label>
                    <div class="input-box">
                        <input name="cfirebate[email]" id="cfirebate:email" title="<?php echo Mage::helper('contacts')->__('Email') ?>" class="input-text required-entry validate-email" type="email" autocapitalize="off" autocorrect="off" spellcheck="false" />
                    </div>
                </div>
            </li>
            <li>
                <label for="cfirebate:telephone"><?php echo Mage::helper('contacts')->__('Phone Number') ?></label>
                <div class="input-box">
                    <input name="cfirebate[telephone]" id="cfirebate:telephone" title="<?php echo Mage::helper('contacts')->__('Phone Number') ?>" class="input-text" type="tel" />
                </div>
            </li>
            <li class="wide">
                <label for="cfirebate:comment"><?php echo Mage::helper('contacts')->__('Comment') ?></label>
                <div class="input-box">
                    <textarea name="cfirebate[comment]" id="cfirebate:comment" title="<?php echo Mage::helper('contacts')->__('Comment') ?>" class="input-text" cols="5" rows="3"></textarea>
                </div>
            </li>
        </ul>
    </div>
    <div class="buttons-set">
        <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);
    var cfiRegionUpdater = new RegionUpdater('cfirebate:country_id', 'cfirebate:region', 'cfirebate:region_id', <?php echo $directory->getRegionJson() ?>, undefined, 'cfirebate:postcode');
//]]>
</script>

尝试在表单中添加表单键:

<input type="hidden" name="form_key" value="<?php echo $this->getFormKey(); ?>">

只需将上述代码添加到表单标记内的任意位置即可。