/** * Validate ActiveRecord model and generate error & warning * If validation is successful then it will display all other buttons in form * @param integer $id * @return mixed */ public function actionValidate($id = 0) { $model = $this->findModel($id); $data = $model->checkError(true); if (isset($data['errors'])) { $data['html'] = ''; foreach ($data['errors'] as $type => $errordata) { if ($type == 'error') { $class = 'alert-danger'; $icon = 'fa fa-ban'; } elseif ($type == 'warning') { $class = 'alert-warning'; $icon = 'fa fa-warning'; } else { $class = 'alert-info'; $icon = 'fa fa-info'; } foreach ($errordata as $field => $message) { $data['html'] .= \yii\adminUi\widget\Alert::widget(['options' => ['class' => $class . ' alert-dismissable'], 'icon' => $icon, 'closeButton' => [], 'body' => $field . ': ' . $message]); } } } header("content-type:application/json"); echo \yii\helpers\Json::encode($data); Yii::$app->end(); }
<p><?php echo $flash; ?> </p> <?php Alert::end(); } if ($flash = Yii::$app->session->getFlash("restaurant_chian_notification_error")) { Alert::begin(['options' => ['class' => 'alert-danger alert-dismissable'], 'icon' => 'fa fa-info', 'closeButton' => []]); ?> <p><?php echo $flash; ?> </p> <?php Alert::end(); } Row::begin(); Column::begin(); Box::begin(['type' => Box::TYPE_INFO, 'header' => $this->title, 'headerIcon' => 'fa fa-gear']); echo $this->render('_restaurant_search', ['model' => $searchModel, 'restaurantDetails' => $restaurantDetails]); $queryArray = yii::$app->getRequest()->getQueryParams(); if ($queryArray['RestaurantSearch']) { $form = ActiveForm::begin(['action' => ['tag'], 'method' => 'post']); echo Html::submitButton('Allocate', ['class' => 'btn btn-success']); echo GridView::widget(['filterPosition' => false, 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'tableOptions' => ['class' => 'table table-bordered'], 'columns' => ['Id', 'name', 1 ? ['class' => 'yii\\grid\\CheckboxColumn', 'multiple' => false] : []]]); echo Html::input('hidden', 'chainId', $restaurantDetails->Id); ActiveForm::end(); } Box::end(); Column::end();