如何在“提交”操作中关闭弹出对话框?现在弹出窗口关闭但它呈现为空页面,
我的观看代码,
<?php
echo CHtml::form('','post',array('enctype'=>'multipart/form-data'));
echo CHtml::activeFileField($model, 'name');
echo CHtml::submitButton('Submit', array('submit' => 'SaveAttachDocuments'));
echo CHtml::endForm();?>
我的控制器代码,
public function actionSaveAttachDocuments()
{
$model=new DocumentAttachmentModel();
// Uncomment the following line if AJAX validation is needed
$filename =CUploadedFile::getInstance($model,'name');
echo "model -> ".$filename;
$model->type =pathinfo($filename, PATHINFO_EXTENSION);
$model->name =pathinfo($filename,PATHINFO_FILENAME);
$model->save();
echo CHtml::script("window.parent.$('#Attach-New-Documents').dialog('close'); window.parent.$.fn.yiiGridView.update('Attach-new-grid');");
Yii::app()->end();
}
答案 0 :(得分:0)
删除此代码行
Yii::app()->end();
然后包含要呈现的视图文件。 (在您的情况下,它应该是根据您的图像包含表单和网格的视图)
$this->render("admin");
所以,如果我把事情放在一起,你的代码应该是,
public function actionSaveAttachDocuments()
{
$model=new DocumentAttachmentModel();
// Uncomment the following line if AJAX validation is needed
$filename =CUploadedFile::getInstance($model,'name');
echo "model -> ".$filename;
$model->type =pathinfo($filename, PATHINFO_EXTENSION);
$model->name =pathinfo($filename,PATHINFO_FILENAME);
$model->save();
echo CHtml::script("window.parent.$('#Attach-New-Documents').dialog('close'); window.parent.$.fn.yiiGridView.update('Attach-new-grid');");
$this->render("admin"); // your view file
}