当我尝试在postlink helper中设置escape为false时,JavaScript警报似乎在Chrome中中断,不知道为什么我没有得到任何控制台错误,它只是在没有初始警报的情况下触发动作。
echo $this->Form->postLink('<i class="icon-trash"></i> Delete',
array('controller' => 'documents', 'action' => 'delete', $document['id']),
array('escape' => false),
null, __('Are you sure you want to delete # %s?', $document['file'])
);
有什么建议吗?
参数个数错误
通过添加escape => false
选项,您忘记为第三个参数删除占位符null
。正因为如此,你现在传递了5个参数。
取出null
,它应该工作;
echo $this->Form->postLink(
// title
'<i class="icon-trash"></i> Delete',
// URL
array('controller' => 'documents', 'action' => 'delete', $document['id']),
// Options
array('escape' => false),
// confirmMessage
__('Are you sure you want to delete # %s?', $document['file'])
);
查看文档;FormHelper::postLink()