Hey I have two tables company and tour. A company can have more than one tour. I can list them all. When I click for update and decide to not to update( cancel update button) I want to go back to the company/view.php file which includes all other tours that company has…
This is my updatecontroller.
public function actionUpdate($id) {
$company= ArrayHelper::map(Company::find()->all(),'id','name');
$model = CompanyPerson::findOne($id);
if ($model->load(Yii::$app->request->post()) && $model->validate())
{
$model->save();
Yii::$app->session->setFlash('success', ' updated');
return $this->redirect(Url::to(['company/view', 'id' => $id]));
}
return $this->render('update',[
'model' => $model,
'company' => $company
]);
in the update.php view file
<a href="<?php echo Url::to(['company/view', 'id'=> $model -> id]); ?>" class="btn btn-app">
<i class="fa fa-ban"></i> Cancel
</a>
The cancel button assign the the company-person id number to the company_id. Since there is no record in that company_id number, It wont display any thing. hope I explained well. Thanks in advance