I have implemented the update and create functionality for my website.
I have a page for items. On the index page I show all the items and there is a create button to create a new item and an update button against each item to update a particular item.
The create and update forms are displayed below the list of items on the index page using ajax call, I call the actionUpdate and actionCreate and render the forms on the index page using the renderPartial.
If the update or create is success, the index page is reloaded.
I do not want to reload the entire page but just the list of items.
Here is the code snippet of my create action:
public function actionCreate() {
$model = new Item();
if( $model->load( Yii::$app->request->post() ) && $model->save() )
{
$items= Item::find()->all();
return $this->redirect(['index', 'items' => $items]);
exit;
}
return $this->renderPartial('createUpdate', ['item' => $model, 'title' => "Create item" ]);
}
Is there a way to achieve this?
-Nishi