在产品页面的弹出窗口中使用登录表单

Login form using in popup on product page

我正在使用产品视图页面上的登录表单 div 弹出窗口。

表单代码

<form action="<?php echo $custmlogin->getPostActionUrl() //echo $this->getPostActionUrl() ?>" method="post" id="login-form">
    <?php  //$this->getBlockHtml('formkey'); ?>
    <input name="form_key" type="hidden" value="<?php  echo Mage::getSingleton('core/session')->getFormKey() ?>" />
    <div class="account-login"  >
    <div class="row">

        <div class="col-sm-6 registered-users">
            <div class="content">
                <h2><?php echo $this->__('Registered Customers') ?></h2>
                <p><?php echo $this->__('If you have an account with us, please log in.') ?></p>
                <ul class="form-list">
                    <li>
                        <label for="email" class="required"><em>*</em><?php echo $this->__('Email Address') ?></label>
                        <div class="input-box">
                            <input type="text" name="login[username]" value="<?php echo $this->escapeHtml($this->getUsername()) ?>" id="email" class="input-text required-entry validate-email" title="<?php echo $this->__('Email Address') ?>" />
                        </div>
                    </li>
                    <li>
                        <label for="pass" class="required"><em>*</em><?php echo $this->__('Password') ?></label>
                        <div class="input-box">
                            <input type="password" name="login[password]" class="input-text required-entry validate-password" id="pass" title="<?php echo $this->__('Password') ?>" />
                        </div>
                    </li>
                    <?php echo $this->getChildHtml('form.additional.info'); ?>
                    <?php echo $this->getChildHtml('persistent.remember.me'); ?>
                </ul>
                <?php echo $this->getChildHtml('persistent.remember.me.tooltip'); ?>
                <p class="required"><?php echo $this->__('* Required Fields') ?></p>
            </div>
            <div class="buttons-set">
                <a href="<?php echo $this->getForgotPasswordUrl() ?>" class="f-left"><?php echo $this->__('Forgot Your Password?') ?></a>
                <button type="submit" class="button" title="<?php echo $this->__('Login') ?>" name="send" id="send2"><span><span><?php echo $this->__('Login') ?></span></span></button>
            </div>
        </div>
    </div>
    </div>
    <?php if (Mage::helper('checkout')->isContextCheckout()): ?>
        <input name="context" type="hidden" value="checkout" />
    <?php endif; ?>
</form>

Jquery代码

var dataForm = new VarienForm('login-form', true);
function prepareSubmit(data){
var response = languagePopupShow();
if(response)
productAddToCartForm.submit(data);}
function languagePopupShow(){
jQuery( ".account-login" ).dialog();
//var url='<?php echo Mage::getUrl("customer/form/login") ?>';}

然后点击按钮

<button type="button" title="<?php echo $buttonTitle ?>" id="popup" href="javascript:;" class="button btn-cart" onclick="prepareSubmit(this)"><span><span><i class="icon-cart"></i><?php echo $buttonTitle ?></span></span></button>

当我在产品页面上使用相同的表单时,它可以工作,但是当在弹出窗口上使用时,它就不起作用。

我已经检查了您的代码,我可以看到帐户登录 div 显示在弹出窗口中,因此请使用帐户登录 div 下面的表单标签。 然后表单标签将显示在您的弹出窗口中,如下面的代码:

<div class="account-login"  >
<form action="<?php echo $custmlogin->getPostActionUrl() //echo $this->getPostActionUrl() ?>" method="post" id="login-form">
<?php  //$this->getBlockHtml('formkey'); ?>
<input name="form_key" type="hidden" value="<?php  echo Mage::getSingleton('core/session')->getFormKey() ?>" />
<div class="row">

    <div class="col-sm-6 registered-users">
        <div class="content">
            <h2><?php echo $this->__('Registered Customers') ?></h2>
            <p><?php echo $this->__('If you have an account with us, please log in.') ?></p>
            <ul class="form-list">
                <li>
                    <label for="email" class="required"><em>*</em><?php echo $this->__('Email Address') ?></label>
                    <div class="input-box">
                        <input type="text" name="login[username]" value="<?php echo $this->escapeHtml($this->getUsername()) ?>" id="email" class="input-text required-entry validate-email" title="<?php echo $this->__('Email Address') ?>" />
                    </div>
                </li>
                <li>
                    <label for="pass" class="required"><em>*</em><?php echo $this->__('Password') ?></label>
                    <div class="input-box">
                        <input type="password" name="login[password]" class="input-text required-entry validate-password" id="pass" title="<?php echo $this->__('Password') ?>" />
                    </div>
                </li>
                <?php echo $this->getChildHtml('form.additional.info'); ?>
                <?php echo $this->getChildHtml('persistent.remember.me'); ?>
            </ul>
            <?php echo $this->getChildHtml('persistent.remember.me.tooltip'); ?>
            <p class="required"><?php echo $this->__('* Required Fields') ?></p>
        </div>
        <div class="buttons-set">
            <a href="<?php echo $this->getForgotPasswordUrl() ?>" class="f-left"><?php echo $this->__('Forgot Your Password?') ?></a>
            <button type="submit" class="button" title="<?php echo $this->__('Login') ?>" name="send" id="send2"><span><span><?php echo $this->__('Login') ?></span></span></button>
        </div>
    </div>
</div>
<?php if (Mage::helper('checkout')->isContextCheckout()): ?>
    <input name="context" type="hidden" value="checkout" />
<?php endif; ?>

在您的代码中,帐户登录 div 显示在弹出窗口中,请在帐户登录 div 下方使用表单标签,它将像下面的代码一样显示在您的弹出窗口中:

<div class="account-login" >

<form action="<?php echo $custmlogin->getPostActionUrl() //echo $this->getPostActionUrl() ?>" method="post" id="login-form">
<?php  //$this->getBlockHtml('formkey'); ?>
<input name="form_key" type="hidden" value="<?php  echo Mage::getSingleton('core/session')->getFormKey() ?>" />
<div class="row">

    <div class<span class="pun" style="margin: 0px; padding: 0px; border:

我在表单中使用表单,所以我更改了代码在文件中的位置,并更改了基于 url 的表单操作路径。