There is a method for updating the page with ajax.

public function actionUpdate( $id ) { $page = Page::find( $id )->one(); if ( Yii::$app->request->post() ) { $page->attributes = \Yii::$app->request->post('Page'); if ( $page->validate() && $page->save() ) { return $this->actionUpdate( $page->id ); } } if( $page !== null ) { if ( Yii::$app->request->isAjax ) { return $this->renderAjax( '_form', [ 'model' => $page ] ); } else { return $this->render( 'update', [ 'model' => $page ] ); } } else { throw new \yii\web\NotFoundHttpException('Page not found'); } } 

After the update you need to stay on the edited page, updating the info. But the problem is that it goes into a cycle, i.e. I get something like recursion :(

  • haven't tried pjax? and what did not fit if you tried? - kandellak
  • About pjax in the course, but I do not see much sense in it. As it says here stackoverflow.com/questions/5612462/how-is-pjax-working It's just a wrapper around "$ .ajax ()" - Guest
  • Maybe you need to make return $this->renderAjax('_form') or return ['success' => $page->save()]; - Alexey Shimansky
  • Thanks, so did return $this->renderAjax('_form') Although strange, return seems to be supposed to stop further script execution return $this->actionUpdate( $page->id ); And he chases him in a circle: ( - Guest
  • well here as .. at the beginning the right part is executed, and then return is done, for example return 2+3; addition will be executed at the beginning ..... respectively, you always want to perform an action update at the beginning, and it doesn’t reach return respectively - Alexei Shimansky

0