发布

时间:2015-07-22 21:52:44

标签: php cakephp post

我正在为JobOffers开发CakePHP 2.x插件。要删除管理面板中的作业,我有以下ctp:

<form method="post" action="/path/to/controller/action/<?php echo $offer['JobOffer']['id']; ?>">
  <input type="hidden" name="data[id]" value="<?php echo $offer['JobOffer']['id']; ?>">
  <button type="submit" class="btn btn-sm btn-danger"><i class="fa fa-trash-o"></i></button>
</form>

使用该表格我称之为:

public function office_delete($id = null) {
  if($this->request->is('post')) {
    $offerId = $this->request->data('id');

    if ($this->JobOffer->delete($offerId)) {
      $this->Session->setFlash('Joboffer deleted.', 'success');
    }
    return $this->redirect(array('action' => 'index'));
  }
  else {
    $this->reportErrors($this->JobOffer->validationErrors, "JobOffer not deleted.");
}

此操作正常,但删除作业后不会重定向。在调试模式下,它只发送一些消息(与模型相关)但有一个空白页面。

我也尝试过referer()。

路由器看起来像这样:

Router::connect(
  '/path/to/action/:id',
  array(
    'plugin' => 'job_offers',
    'controller' => 'job_offers',
    'action' => 'delete',
    'office' => true)
);

任何人

0 个答案:

没有答案
相关问题