当我将类数组添加到postLink时,确认警报停止工作。我已经将类数组移到了不同的位置,但在postLink中,但似乎什么都不起作用。
<?= $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 %>)]) %>
上面的代码会将正确的类添加到链接中,但确认不起作用,它只是立即删除条目。
confirm
消息和其他html选项(如class
)位于同一数组中
<?= $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 %>)]) %>