在FormHelper :: postLink()中禁用转义会中断警报确认

dcd*_*181 2 html php cakephp cakephp-2.0

当我尝试在postlink帮助器中将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'])
);
Run Code Online (Sandbox Code Playgroud)

有什么建议?

tha*_*tah 8

参数数量错误

通过添加该escape => false选项,您忘记删除null第三个参数的占位符.因此,你现在传递了五个参数.

删除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'])
);
Run Code Online (Sandbox Code Playgroud)

参见文档; FormHelper::postLink()