Is there a way to easily have multiple buttons within a form which go to different actions from within the controller.
Ie a form populated from a model and then have ‘Save’,‘Update’ & ‘Delete’ buttons.
Or would this require just having different buttons and having a custom js script which runs ajax to the controller.
alex-w
(Pr0j3ct A1ex)
2
Why not just have a "Save" button?
The "Save" method in AR will update/create.
Save does the save and update you are correct. But I would like a delete button and possibly another button to do a different function.
Don’t see a problem with this. Are you facing any issue doing this?
Hi Kartik, the save/update works fine, but im not sure how to add another button within the form which goes to another action.
As simple as… 
echo Html::a('Delete', ['/controller/delete', 'id'=>$model->id], ['class'=>'btn btn-danger']);
One Other question though, I am having problems removing the get parameter from within the url.
I am doing this within my delete action:
$model = new Supplier();
if(Yii::$app->request->isGet)
{
$model->suppliercode = $id;
if($model->deletesupplier())
{
return $this->render('/');
}
}
It just reloads the page with the get parameters still there.
Use the refresh method as below:
$model = new Supplier();
if(Yii::$app->request->isGet)
{
$model->suppliercode = $id;
if($model->deletesupplier())
{
return $this->refresh();
}
}
Thanks Kartik will give that a go tomorrow.