0

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(&quot;Are you sure you want to delete # 1836?&quot;)) { document.post_573da0811d667564814578.submit(); } event.returnValue = false; return false;" href="#">Delete</a>
xDs
  • 403
  • 8
  • 23
  • Please always mention your _exact_ CakePHP version and tag your question accordingly - thanks! Also please add some more context around your `postLink()` call (mostly important is whether it is being invoked inside of an open form), and show the generated HTML. – ndm May 19 '16 at 11:50
  • Added some extra info under 'Update'. – xDs May 19 '16 at 12:16
  • Didn't realise it became a form inside another form. Thanks for the reaction. – xDs May 19 '16 at 13:41

0 Answers0