【发布时间】:2016-06-08 05:07:01
【问题描述】:
在我的 Yii Web 应用程序中,当在登录表单中按下“输入”键时,CHtml 提交按钮不起作用。我的登录表单是,
<?php echo CHtml::beginForm(); ?>
<h3 class="form-title">Login to your account</h3>
<div class="alert alert-danger display-hide">
<button class="close" data-close="alert"></button>
<span> Enter any username and password. </span>
</div>
<div class="form-group">
<label class="control-label visible-ie8 visible-ie9">Username</label>
<div class="input-icon">
<i class="fa fa-user"></i>
<?php echo CHtml::activeTextField($model, 'username', array("class" => "form-control placeholder-no-fix", 'placeholder' => "Username")) ?>
</div>
</div>
<div class="form-group">
<label class="control-label visible-ie8 visible-ie9">Password</label>
<div class="input-icon">
<i class="fa fa-lock"></i>
<?php echo CHtml::activePasswordField($model, 'password', array("class" => "form-control placeholder-no-fix", 'placeholder' => "Password")) ?>
</div>
</div><br>
<div class="form-group">
<?php echo CHtml::submitButton(UserModule::t("Login "), array('class' => 'btn green pull-right')); ?>
</div>
<div class="text-danger"><?php echo CHtml::errorSummary($model); ?></div>
<?php echo CHtml::endForm(); ?><br><br><br>
<?php
$form = new CForm(array(
'elements' => array(
'username' => array(
'type' => 'text',
'maxlength' => 32,
),
'password' => array(
'type' => 'password',
'maxlength' => 32,
),
'rememberMe' => array(
'type' => 'checkbox',
)
),
'buttons' => array(
'login' => array(
'type' => 'submit',
'label' => 'Login',
),
),
), $model);
?>
在此登录表单中使用 chtml 提交按钮。我想按回车键提交此登录表单。 如何解决这个问题。 请帮帮我。
【问题讨论】:
-
UserModule::t("Login") ,这里你使用 usermodule::t 的目的是什么?
-
实际上 UserModule::t("Login ") 仅用于标签。
-
只需在提交按钮中使用onclick事件进行重定向。
-
如何在 CHtml::submitButton 中提供 onclick 事件
-
您的自定义“form-control”和/或“placeholder-no-fix”html 类上是否有使用 Javascript 的事件监听器?可能您正在使用 Javascript 在这些字段或所有表单上过滤 ENTER 按键
标签: yii