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

时间:2017-04-05 12:00:26

标签: jquery magento customer

我正在使用产品视图页面上的登录表单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>

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

3 个答案:

答案 0 :(得分:0)

我已经检查了你的代码,我可以看到帐户登录div显示在弹出窗口中,所以请使用account-login 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; ?>

    

答案 1 :(得分:0)

在您的代码中,帐户登录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:

答案 2 :(得分:0)

我在表单中使用表单,因此我更改了文件中代码的位置,并使用基本URL更改表单操作路径。