actionIndex
, в котором происходит обработка формыpublic function actionIndex()
{
$this->layout = 'template-index';
$category = Category::find()->all();
$collection = Collection::find()->all();
$model = new Callrequest();
if ($model->load(Yii::$app->request->post()) && $model->validate() && $model->save()) {
if ($model->sendEmail(Yii::$app->params['adminEmail'])) {
Yii::$app->session->setFlash('success', 'Thank you for contacting us. We will respond to you as soon as possible.');
} else {
Yii::$app->session->setFlash('error', 'There was an error sending your message.');
}
return $this->refresh();
} else {
return $this->render('index',
[
'category' => $category,
'collection' => $collection,
'model' => $model
]);
}
}