/** * Finds the Fields model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $id * @return Fields the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Fields::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function actionDeleteField() { if (Yii::$app->request->isAjax) { if (isset($_POST['id'])) { $bool = Fields::findOne(['id' => $_POST['id']])->delete(); if ($bool) { } } } }