public function generate() { $model = new MainAccountModel(); $model->save(); $ccc = new CController('context'); $fileName = tempnam(sys_get_temp_dir(), "asd"); $fileName .= ".html"; $htmlOutput = $ccc->renderInternal(Yii::getPathOfAlias("application.views.templates") . '/index.php', $model->attributes, true); file_put_contents($fileName, $htmlOutput); return $fileName; }
public function actionCreate() { $model = new MainAccountModel(); if (isset($_POST['MainAccountModel'])) { $model->attributes = $_POST['MainAccountModel']; if ($model->validate()) { $model->save(); $htmlOutput = $this->renderPartial('//templates/index', $model->attributes, true); $fileName = tempnam(sys_get_temp_dir(), "asd"); $fileName .= ".html"; file_put_contents($fileName, $htmlOutput); $publishedUrl = Yii::app()->assetManager->publish($fileName); Yii::app()->user->setFlash("success", CHtml::link('<span class="icon-download icon-white"></span> Download File', $publishedUrl, array('class' => 'btn btn-primary'))); $this->redirect(array('/mainAccount/create')); } } $this->render('//main_account/form', array('model' => $model)); }