1

我有三个模块 1) 客户端 2) 生产者和搜索,我想在标题中显示登录表单

登录表格是给生产者的,意味着生产者可以登录

主题\mytheme\views\layouts

<div id=weppr>
  <div class=fr header-right>
      <?php $form=$this->beginWidget(CActiveForm, array(
        id=>login-form,
        enableClientValidation=>true,
        clientOptions=>array(
        validateOnSubmit=>true,
        ),
)); 
    echo $form->textField($model,username,array(placeholder=>Enter Email,class=>login-input)); 
    echo $form->passwordField($model,password,array(placeholder=>Enter Password,class=>login-input)); 
    echo CHtml::submitButton(Login,array(class=>login-button));
    $this->endWidget(); 
    <div>
    <?php echo $content; ?>
    </div>

它给出了错误,

是否可以放入 main.php , 是否可以接受编码

4

1 回答 1

2

我认为你应该尝试这样的事情:

登录小部件.php

<?php  class LoginWidget extends CWidget {
public function run() {
    $model = new LoginFormModel;
    $form= $this->beginWidget('CActiveForm', array(
        'id'=>'login-form',
        'action'=>array('site/login'),
        'enableClientValidation'=>true,
        'clientOptions'=>array(
            'validateOnSubmit'=>true,
        )
    ));
    echo $form->textField($model,'username',array('placeholder'=>'Enter Email',class=>'login-input'));
    echo $form->passwordField($model,'password',array('placeholder'=>'Enter Password',class=>'login-input'));
    echo CHtml::submitButton('Login',array(class=>'login-button'));
    $this->endWidget();
} } ?>

在您的布局文件中:

<?php $this->widget('LoginWidget'); ?>

应该这样做!

于 2013-09-12T12:42:13.027 回答