public function actionSave()
    {
        $post = Yii::$app->request->post();
        $id = $post['Note']['id'];
        if($id) {
            $model = Note::findOne($id);
        } else {
            $model = new Note;
        }
        Yii::$app->response->format = 'json';
        if ($model->load(Yii::$app->request->post()) && $model->save()) {
            return ['success' => true];
        } else {
            return ['success' => false, 'errors' => $model->getErrors()];
        }
    }
public function actionSave()
    {
        $post = Yii::$app->request->post();
        $id = $post['Note']['id'];
        if($id) {
            $model = Note::findOne($id);
        } else {
            $model = new Note;
        }
        Yii::$app->response->format = 'json';
        if ($model->load(Yii::$app->request->post()) && $model->save()) {
            return ['success' => true];
        } else {
            return ['success' => false, 'errors' => $model->getErrors()];
        }
    }
public function actionSave ( ) { $ post = Yii :: $ app -> request -> post ( ) ; $ id = $ post [ 'Note' ] [ 'id' ] ; if ( $ id ) { $ model = Note :: findOne ( $ id ) ; } else { $ model = new Note ; } Yii :: $ app -> response -> format = 'json' ; if ( $ model -> load ( Yii :: $ app -> request -> post ( ) ) && $ model -> save ( ) ) { return [ 'success' => true ] ; } else { return [ 'success' => false , 'errors' => $ model -> getErrors ( ) ] ; } }
Saves a model.
If creation is successful, the browser will be redirected to the 'view' or 'index' page.
@return mixed
Saves a model . If creation is successful the browser will be redirected to the view or index page .