表单提交后没有值 [ 新手入门 ]
view
<?php $form=$this->beginWidget('CActiveForm',array('action'=>array('test/add')));?>
<?php
$model=new Test;
echo CHtml::errorSummary($model); ?>
<div style="width: 900px; height: auto; margin-left: 20%;">
<div style="text-align: left;">
<!-- <input type="button" value="添加" style="text-align: center; width: 80px;" onclick="show();"></input>-->
<?php echo CHtml::button('添加', array('onclick'=>'show()','style'=>'width:80px;text-align:center;')) ?>
<script>
function show(){
document.getElementById('screm').style.display='block';
document.getElementById('screm_1').style.display='block';
}
</script>
</div>
<div id="screm" style="width: 900px; height: 565px; position: absolute; z-index: 99;display: none; background-color: black; filter:alpha(opacity=40); ">
</div>
<div id="screm_1" style="width: 900px; height: 565px; position: absolute; z-index: 9999;display: none;">
<div style="width: 200px; height: 150px; border: 2 solid #09f; margin-left: 40%; margin-top: 15%; background-color: white;">
<br/>
<div style="width: 200px; height: 50px;">
title:
<br/>
<?php echo $form->labelEx($model,'title'); ?>
<?php echo $form->textField($model,'title',array('size'=>80,'maxlength'=>128,'style'=>'width:150px;')); ?>
<?php echo $form->error($model,'title'); ?>
</div>
<div style="width: 200px; height: 60px;">
content:
<br/>
<?php echo $form->labelEx($model,'content'); ?>
<?php echo CHtml::activeTextArea($model,'content',array('rows'=>10, 'cols'=>20)); ?>
<?php echo $form->error($model,'content'); ?>
</div>
<div style="width: 200px; height: 50px;">
<?php echo CHtml::submitButton('提交'); ?>
<input type="button" value="关闭" onclick="close_1();"></input>
<script>
function close_1(){
document.getElementById('screm').style.display='none';
document.getElementById('screm_1').style.display='none';
}
</script>
</div>
</div>
</div>
<div style="width: 900px; height: auto;">
<?php $this->widget('zii.widgets.grid.CGridView', array(
'dataProvider'=>$model->search(),
'filter'=>$model,'hideHeader'=>false,
'columns'=>array(
array(
'name'=>'title',
'type'=>'raw',
'value'=>'CHtml::link(CHtml::encode($data->title), $data->url)',
),
array(
'name'=>'create_time',
'type'=>'datetime',
'filter'=>false,
),
array(
'header'=>'操作',
'class'=>'CButtonColumn',
),
),
)); ?>
</div>
</div>
<?php $this->endWidget(); ?>[/code]controllor[code] public function actionAdd(){
$test=new Test();
if(isset($_POST['Test'])){
$model->attributes=$_POST['Test'];
if(Test::model()->save())
$this->redirect (array('index'));
}
}
共 2 条回复
kwt90 烟台
注册时间:2012-02-21
最后登录:1970-01-01
在线时长:0小时0分
最后登录:1970-01-01
在线时长:0小时0分
- 粉丝0
- 金钱15
- 威望0
- 积分15