【发布时间】:2014-04-09 09:39:29
【问题描述】:
我开始在 magento 上运气好几个星期了。此后的挑战。我试图在我的输入框上方显示消息但无济于事。下面是我的 phtml 和控制器。
密码.phtml
<div id="account-profile">
<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
<form action="<?php echo Mage::getUrl('customer/account/emailopt'); ?>" method="post">
<input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
<div class="fieldset">
<ul class="form-list">
<li class="fields">
<div class="field">
<div class="input-box">
<label for="email"><?php echo $this->__('Email') ?><span class="required">*</span></label>
<input name="email" id="email" title="Email" value="" class="required-entry input-text validate-email" type="text" />
</div>
</div>
</li>
</ul>
</div>
<button type="submit" class="btn-dbbdr" title="<?php echo $this->__('Edit Options') ?>"><span><span><?php echo $this->__('Edit Options') ?></span></span></button>
</form>
accountController.php
public function emailoptAction()
{
if (!$this->_validateFormKey()) {
return $this->_redirect('*/emailoptions');
}
$customer = Mage::getSingleton('customer/session')->getCustomer();
$email = $customer->getEmail();
$_email =$this->getRequest()->getParam('email');
if ($email != $_email) {
echo 'This is not your valid email';
} else {
echo 'proceed here';
}
$this->_redirect('*/emailoptions');
}
这里发生的事情是每次我单击提交时,它只是回显消息,然后再次重定向到该页面。
【问题讨论】:
标签: validation magento email post input