// In the view file 'my-pjax']); ?>
Name | Age | |
---|---|---|
name ?> | age ?> | email ?> |
// In the view file 'my-pjax']); ?> ['data-pjax' => true]]); ?> field($model, 'name') ?> field($model, 'age') ?> field($model, 'email') ?>This example uses Pjax to update a user form without reloading the entire page. The view file includes the Pjax::begin() and Pjax::end() widgets and the form is submitted with the 'data-pjax' attribute set to true. The controller action checks whether the request is a Pjax request before rendering the view or the partial view. Package library: yii2-pjax (https://github.com/yiisoft/yii2-pjax)'btn btn-primary']) ?>// In the controller action public function actionUpdate($id) { $model = User::findOne($id); if ($model->load(Yii::$app->request->post()) && $model->save()) { if (Yii::$app->request->isPjax) { return $this->renderPartial('_form', ['model' => $model]); } return $this->redirect(['view', 'id' => $model->id]); } return $this->render('update', ['model' => $model]); } // In the partial view file ['data-pjax' => true]]); ?> field($model, 'name') ?> field($model, 'age') ?> field($model, 'email') ?>'btn btn-primary']) ?>