如何在layout/main.php中集成YII用户模块的登录表单 如何在layout/main.php中集成YII用户模块的登录表单
我想知道如何使用Yii用户模块中的登录表单和注册表单进入layouts/main.php,比如facebook索引页面。如果有人能告诉我详细信息如何在layout/main.php中集成YII用户模块的登录表单 如何在layout/main.php中集成YII用户模块的登录表单,yii,yii-extensions,yii-components,Yii,Yii Extensions,Yii Components,我想知道如何使用Yii用户模块中的登录表单和注册表单进入layouts/main.php,比如facebook索引页面。如果有人能告诉我详细信息 提前感谢…您需要使用小部件。下面是一个关于制作小部件的短期速成课程: 创建LoginFormWidget.php此处:/protected/components/LoginFormWidget.php 在此处为小部件创建视图文件夹/protected/components/views/ 为您的LoginFormWidget创建视图文件,如下所示:/pr
提前感谢…您需要使用小部件。下面是一个关于制作小部件的短期速成课程:
LoginFormWidget.php
此处:/protected/components/LoginFormWidget.php
/protected/components/views/
LoginFormWidget
创建视图文件,如下所示:/protected/components/views/LoginFormWidget.php
LoginFormWidget.php
文件中:
class LoginFormWidget extends CWidget
{
/**
* Is called when $this->beginWidget() is called
*/
public function init()
{
}
/**
* Is called when $this->endWidget() is called
*/
public function run()
{
$model = new LoginForm;
$this->render('loginFormWidget', array('model'=>$model));
}
}
<div class="form">
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'login-form',
'enableAjaxValidation'=>true,
'clientOptions'=>array('validateOnSubmit'=>true),
'htmlOptions'=>array('class'=>'customClass'),
'action' => array('site/login'), // this is is the action that's going to process the data
)); ?>
<?php echo $form->labelEx($model,'email'); ?>
<?php echo $form->textField($model,'email'); ?>
<?php echo $form->error($model,'email'); ?>
<?php echo $form->labelEx($model,'password'); ?>
<?php echo $form->passwordField($model,'password'); ?>
<?php echo $form->error($model,'password'); ?>
<?php echo CHtml::submitButton('Log in!'); ?>
<?php $this->endWidget(); ?>
</div>
如果您有一个单独的登录表单,那么您可以在Cmenu中使用它。您也可以为此制作一个小部件,但也可以呈现表单。如果要渲染表单,则可以这样做
$form=$this->renderPartial('loginForm');
现在,在Cmenu小部件中,您必须将属性'encodeLable'
更改为false
如
$this->widget('zii.widgets.CMenu', array(
'encodeLabel'=>false,
'items'=>array(
array('label'=>$form, 'url'=>array('site/index')),
),
));
您使用的是引导还是简单的Cmenu?谢谢兄弟。还有一个问题,我可以为Main中的include注册表执行此操作吗?是的,您可以为控制器/操作执行的几乎所有功能执行此操作。