Search code examples
cakephpform-helperscakephp-3.0

CakePHP 3.0 - How to create a postLink with confirmMessage?


I started working in CakePHP 3.0 (beta) today.

In CakePHP 2.0 there was an option for adding a confirm message to a postlink. This would result in an alert when clicking on the link.

More info about the postLink in CakePHP 2.0: http://book.cakephp.org/2.0/en/core-libraries/helpers/form.html#FormHelper::postLink

More info about the postLink in CakePHP 3.0: http://book.cakephp.org/3.0/en/views/helpers/form.html#Cake\View\Helper\FormHelper::postLink

In the 3.0 version the confirmMessage is gone. Does anybody know if CakePHP 3.0 has an alternative for this?


Solution

  • It's not gone, it was just moved into an option named confirm:

    $this->Form->postLink('title', 'url', ['confirm' => 'Are you sure?'])
    

    See also http://api.cakephp.org/3.0/class-Cake.View.Helper.FormHelper.html#_postLink