Commit 1590e296 authored by Shakarim Sapa's avatar Shakarim Sapa

- Перенаправили добавление записи на подписку в другой экшн (аналогичный)

parent bdae6efc
......@@ -21,6 +21,7 @@ class BidController extends \common\components\BaseController
{
return [
'Add' => 'Добавление заявки',
'BlogAdd' => 'Добавление заявки в блог',
'Upload-files' => 'Загрузка файлов',
];
}
......@@ -79,6 +80,61 @@ class BidController extends \common\components\BaseController
}
}
/**
* @return array
* @throws \Exception
* @throws \yii\web\NotFoundHttpException
*/
public function actionBlogAdd()
{
Yii::$app->response->format = Response::FORMAT_JSON;
$model = new Bid;
$model->scenario = Yii::$app->request->post('scenario');
if(Yii::$app->request->isAjax && $model->load(Yii::$app->request->post()))
{
$transaction = Yii::$app->db->beginTransaction();
try
{
if($model->save())
{
// Yii::$app->user->identity->afterSubscribe(12);
if($model->file)
{
foreach ($model->file as $filename)
{
$file = new BidFile;
$file->bid_id = $model->id;
$file->filename = $filename;
$file->save();
}
}
$model->send();
$transaction->commit();
return ['success' => true];
}
else
{
return ActiveForm::validate($model);
}
}
catch (Exception $e)
{
$transaction->rollBack();
throw $e;
}
}
else
{
throw new NotFoundHttpException('The requested page does not exist.');
}
}
public function actionUploadFiles()
{
......
......@@ -15,7 +15,7 @@ use common\modules\bids\models\Bid;
$model->form = Bid::FORM_SUBSCRIBE;
$form = ActiveForm::begin([
'action' => '/bids/bid/add',
'action' => '/bids/bid/blogAdd',
'enableClientValidation' => false,
'options' => [
'class' => 'subsc_blog_form bids-form',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment