PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, February 22, 2022

[FIXED] CakePHP 3.0 - Post Link - adding classes removes alert confirmation functionality

 February 22, 2022     cakephp, cakephp-3.0, php     No comments   

Issue

When I add the class array to the postLink, the confirm alert stops working. I have moved the class array into different positions but within the postLink but nothing seems to work.

<?= $this->Form->postLink(__('Delete'),
['controller' => '<%= $details['controller'] %>', 'action' => 'delete', <%= $otherPk %>],
['class' => 'btn btn-danger btn-sm'],
['confirm' => __('Are you sure you want to delete # {0}?', <%= $otherPk %>)]) %>

The above code will add the right classes to the link, but the confirmation doesn't work, it just deletes the entry right away.


Solution

the confirm message and the other html options like class go in the same array

<?= $this->Form->postLink(__('Delete'),
    ['controller' => '<%= $details['controller'] %>', 'action' => 'delete', <%= $otherPk %>],
    ['class' => 'btn btn-danger btn-sm'],'confirm' => __('Are you sure you want to delete # {0}?', <%= $otherPk %>)]) %>


Answered By - arilia
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing