不要重定向动作cakephp 3

时间:2017-05-19 17:26:15

标签: cakephp-3.0

当我点击保存此作业按钮时,会重定向到Jobsaves / savejobs / 1。如何不重定向,留在此页面job / view / 1

在Jobsaves控制器

 if ($this->Jobsaves->save($jobsave)) {
               $this->Flash->success(__('The jobsave has been saved.'));
                //return $this->redirect();
            } else {
                $this->Flash->error(__('The jobsave could not be saved. Please, try again.'));
            }

<?php echo $this->Html->Link('Save This Job',['controller'=>'Jobsaves','action'=>'savejob',$job->id],['class'=>'btn btn-success']); ?>

1 个答案:

答案 0 :(得分:1)

我认为你应该像这样重定向到引用者:

if ($this->Jobsaves->save($jobsave)) {
               $this->Flash->success(__('The jobsave has been saved.'));
                return $this->redirect($this->referer());
} else {
                $this->Flash->error(__('The jobsave could not be saved. 
Please, try again.'));
}