public function actionCreate()
{
$model=new Model;
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['Model'])) //<- POST data var
{
$model->attributes=$_POST['Model']; //<- POST data var
if($model->save())
$this->redirect(array('view','id'=>$model->id));
}
$this->render('create',array(
'model'=>$model,
));
}
3条答案
按热度按时间vh0rcniy1#
我不认为CHttpRequest是用来获取post数据的,Yii本身使用了$_POST变量,例如Gii的默认输出可以是:
omvjsjqw2#
You can extendCHttpRequestcomponent and rewrite public methodgetPost()
Do not forget to include the new component class inconfig/main.phpfile:
Now, you can get all**$_POST**data in this way:
wfauudbj3#
您可以使用getRestParams()来获取数组。
或
**引用:**CHttpRequest -获取剩余参数