2015-12-29 13:09:58 2692次浏览 1条回答 0 悬赏 10 金钱

模型:

<?php
class Mrna extends CActiveRecord
{
	public $mrna;
	
	//模型方法
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
	//表名方法
	public function tableName()
	{
		return '{{mrna}}';
	}
	//标签方法
	public function attributeLabels()
	{
		return array(
			'mrna'=>'请输入mRNA序列:',
		);
	}
	public function rules()//验证规则方法
	{
		return array(
				//自定义前台验证规则:表单不能为空
				array('mrna','required','message'=>'内容不能为空'),
		);
	}
}

视图:page1

<?php 
	$form=$this->beginWidget('CActiveForm');
		echo '<div class=\'wlcm1\'>';
		echo $form->labelEx($dnaModel,'field');
		echo $form->dropDownList($dnaModel,'field',array(
				'dna_id'=>'dna_id',
				'Assembly'=>'Assembly',
				'Genome Center name'=>'Genome Center name',
				'RefSeq Accession.version'=>'RefSeq Accession.version',
				'GenBank Accession.version'=>'GenBank Accession.version',
				'NCBI name'=>'NCBI name')
				);
		echo '</div>';
		echo '<div class=\'wlcm2\'>';
		echo $form->labelEx($dnaModel,'val');
		echo $form->textField($dnaModel,'val',array('style'=>'width:300px;'));
		echo '<input type="submit" value="提交"/>';
		echo $form->error($dnaModel,'val');
		echo '</div>';
	$this->endWidget();
 ?>

控制器:

	public function actionPage9(){
		$mrnaModel = Mrna::model();
		if(isset($_POST['Mrna'])){
			$arr = array(
					'mrnaModel'=>$mrnaModel,
					'str'=>$_POST['Mrna']['mrna'],
					'pn'=>'mRNA序列翻译'
			);
		}else{
			$arr = array(
					'mrnaModel'=>$mrnaModel,
					'str'=>'',
					'pn'=>'mRNA序列翻译'
			);
		}
		$this->render('page9',$arr);
	}
您需要登录后才可以回答。登录 | 立即注册
gengzhihuan
助理

gengzhihuan

注册时间:2015-11-08
最后登录:2015-12-30
在线时长:0小时48分
  • 粉丝0
  • 金钱30
  • 威望10
  • 积分130

热门问题