public function actionContact($type = null) { $model = new ContactForm(); $viewName = 'contact'; if ($model->load(Yii::$app->request->post()) && $model->send(Yii::$app->params['adminEmail'])) { Yii::$app->session->setFlash('info', Yii::t('front', 'Your message was successfuly submitted. Thank you!')); return $this->refresh(); } else { if ($type == 'pdf') { /** @noinspection PhpUndefinedFieldInspection */ $pdf = Yii::$app->pdf; $pdf->content = $this->renderPartial('pdf/' . $viewName); $pdf->options['title'] = Yii::t('front', 'Contacts'); $pdf->methods['SetFooter'] = ['{PAGENO}']; return $pdf->render(); } else { return $this->render($viewName, compact('model')); } } }