Yii一般控件使用代码
View
-------------------------------------------------
<?php$this->pageTitle=Yii::app()->name . ' - 总结';$this->breadcrumbs=array('控件使用总结',);?><h1>控件使用总结</h1><tr name="code"><?phpclass WidgetForm extends CFormModel { public $textfiled; // 文本框 public $password; // 密码框 public $dropDownList; // 下拉列表 public $checkBox; // 单复选框 public $checkBoxList; //多复选框 public $radioButtonList; // 单选列表 public function rules() { return array( array('textfiled, password, dropDownList, checkBox, checkBoxList, radioButtonList','safe'), ); } public function attributeLabels() { return array( 'textfiled' => '文本框', 'password' => '密码框', 'dropDownList' => '下拉列表', 'checkBox' => '单选列表', 'checkBoxList' => '多复选框', 'radioButtonList' => '单选按钮', ); } public static function getDropDownListContent(){ $result = array(); for($i=0 ; $i<10; $i++){ $result[$i]='DropDown'.$i; } return $result; } public static function getCheckBoxListContent(){ $result = array(); for($i=0 ; $i<3; $i++){ $result[$i]='CheckBox'.$i; } return $result; } public static function getRadioButtonListContent(){ $result = array(); for($i=0 ; $i<3; $i++){ $result[$i]='RadioButton'.$i; } return $result; } }<?phpclass WidgetController extends Controller { public function actionIndex() { $model = new WidgetForm(); if (isset($_POST['WidgetForm'])) { $model->attributes = $_POST['WidgetForm']; $message = ""; $message = $message . "<br>文本框:" . getType($model->textfiled) . " " . $model->textfiled; $message = $message . "<br>密码框:" . getType($model->password) . " " . $model->password; $message = $message . "<br>单复选框:" . getType($model->checkBox) . " " . $model->checkBox; $message = $message . "<br>多复选框:" . getType($model->checkBoxList) . " " . print_r($model->checkBoxList,true); $message = $message . "<br>下拉列表:" . getType($model->dropDownList) . " " . $model->dropDownList; $message = $message . "<br>单选列表:" . getType($model->radioButtonList) . " " . $model->radioButtonList; $this->render('index', array('model' => $model, 'message' => $message)); } else{ $this->render('index', array('model' => $model)); } }}