cform使用问题:只显示button [ 未指定版本 ]
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
不知道为什么,发了一遍出现了两个相同的帖子,
管理员如果看到可将此贴删除
共 0 个回答
没有找到数据。
sbfnxk201
注册时间:2013-09-20
最后登录:2014-02-26
在线时长:30小时0分
最后登录:2014-02-26
在线时长:30小时0分
- 粉丝0
- 金钱0
- 威望0
- 积分300