getFilterData('and'); $filter[0] = 'and'; TableWidget::widget([ 'top' => [ 'title' => 'Обекти за стани изследовател', 'data' => [ 'index/dashboard' => 'Начало', ] ], 'actions' => [ 'new' => 'Нов обект', 'edit' => 'Редакция обект', 'delete' => 'Изтриване обект' ], 'th' => [ '№' => 'c0 text-right', 'Име на обект' => '', 'Бр. точки' => '' ], 'model' => ExplorerObjects::class, 'data' => ExplorerObjects::find()->where(Yii::$app->getFilterData('and'))->loop([ 'id', function (ExplorerObjects $model) { if($model->tourObject) return '' . $model->tourObject->name . ''; }, 'points' ], $_GET['p'] ?? 1, 50) ]); FormWidget::widget([ 'top' => [ 'title' => 'Нов туристически обект', 'title_edit' => 'Редакция туристически обект', 'data' => [ 'index/dashboard' => 'Начало', 'mobile-app/become-an-explorer-objects' => 'Стани изследовател обекти', ], ], 'tabs' => $tabs ?? [], 'writeView' => "mobile-app/tabs/" . Includes::tab($tab) . "/tour_objects_w", 'model' => ExplorerObjects::class, 'validation' => function ($p) { if (empty($p->{'tour_object_id'})) { return ['tour_object_id' => 'Моля, изберете туристически обект']; } else { $filter = ['tour_object_id' => $p->tour_object_id]; if(!empty($_GET['id'])) $filter = ['and', ['=', 'tour_object_id', $p->tour_object_id], ['!=', 'id', $_GET['id']]]; $exists = ExplorerObjects::find()->where($filter)->exists(); if($exists) return ['tour_object_id' => 'Туристическия обект вече е добавен, моля изберете друг']; } if (empty($p->{'points'})) return ['points' => 'Моля, попълнете брой точки за получаване при посещение на туристическия обект.']; }, 'postService' => function ($p, ExplorerObjects $model) use ($tab) { $model->setPostDataToModel(); $model->save(); Yii::$app->flash('success', isset($_GET['id']) ? 'Данните са записани успешно' : 'Данните са създадени успешно'); $model->smartRedirect(); } ]);