2013-11-18 19:34:47 3085次浏览 0条回答 0 悬赏 10 金钱

model:User.php

<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of User
 *
 * @author Administrator
 */
class User extends CActiveRecord {

    //静态类
    public static function model($className = __CLASS__) {
        return parent::model($className);
    }

    //表名
    public function tableName() {
        return '{{user}}';
    }

    //cform配置文件
    public function getFMConfig() {
        return array(
            'elements' => array(
                'name' => array('type' => 'text', 'maxlength' => 80),
                'password' => array('type' => 'password', 'maxlength' => 80),
            ),
            'buttons' => array(
                'button' => array('type' => 'submit', 'label' => '提交'),
            ),
        );
    }

}
--------------------------------
controller UserController.php
<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of UserController
 *
 * @author Administrator
 */
class UserController extends Controller{
    public function actionRegister(){
        $user = new User();
        $form = new CForm($user->getFMConfig(), $user);

        $this->render('register',array('form'=>$form));
    }

    
}

--------------------------------

view :register.php

<?php echo $form ?>
----------------------------------------------------------------------

现象:只显示提交按钮。不显示,input框

如果在elemtns属性中设置label 属性,也能显示,就是不显示正常input框



问题已解决

答案在 :http://www.yiichina.com/question/79

不知道为什么,发了一遍出现了两个相同的帖子,

管理员如果看到可将此贴删除



    没有找到数据。
您需要登录后才可以回答。登录 | 立即注册
sbfnxk201
见习主管

sbfnxk201

注册时间:2013-09-20
最后登录:2014-02-26
在线时长:30小时0分
  • 粉丝0
  • 金钱0
  • 威望0
  • 积分300

热门问题