I get the following error when using a postLink for deleting a record:
- document.post_573da0811d667564814578 is undefined
This looks like a Javascript error, but I did not add Javascript code myself.
This is my postLink (I use two parameters):
$this->Form->postLink(__('Delete'), ['action' => 'delete', $p->id, $c], ['confirm' => __('Are you sure you want to delete # {0}?', $p->id)])
This is my delete method:
public function delete($id = null, $c = null) {
$this->request->allowMethod(['post', 'delete']);
// some code
return $this->redirect(['action' => 'index', $c]);
}
What could be the problem?
Update
- CakePHP version: 3.2.7
- The postLink is used inside a form.
- The generated html of the postLink:
<a onclick="if (confirm("Are you sure you want to delete # 1836?")) { document.post_573da0811d667564814578.submit(); } event.returnValue = false; return false;" href="#">Delete</a>