Forms 如何使用cakephp和twitter引导在表单postlink中创建图标

Forms 如何使用cakephp和twitter引导在表单postlink中创建图标,forms,twitter-bootstrap,cakephp,tags,glyphicons,Forms,Twitter Bootstrap,Cakephp,Tags,Glyphicons,这就是我想要的: <?php echo $this->Html->link( $this->Html->tag('i', '', array('class' => 'glyphicon glyphicon-edit')) . " Edit", array('action' => 'edit', $comment['Comment']['comment_id']), array('class' => 'btn btn-mini',

这就是我想要的:

<?php echo $this->Html->link(
   $this->Html->tag('i', '', array('class' => 'glyphicon glyphicon-edit')) . " Edit",
   array('action' => 'edit', $comment['Comment']['comment_id']),
   array('class' => 'btn btn-mini', 'escape' => false)
); ?>

但是,当我创建一个表单postLink时,我不知道如何获得它前面的删除图标

<?php echo $this->Form->postLink(
   $this->Html->tag('i', '', array('class' => 'glyphicon glyphicon-remove')) . " Delete",
   array('action' => 'delete', $comment['Comment']['comment_id']), null, __('Are you sure you want to delete # %s?', $comment['Comment']['comment_id']),
   array('class' => 'btn btn-mini', 'escape' => false)
); ?>


它给我
Delete

你忘了添加
escape
选项到
false

echo $this->Form->postLink(
   $this->Html->tag('i', '', array('class' => 'glyphicon glyphicon-remove')). " Delete",
        array('action' => 'delete', $comment['Comment']['comment_id']),
        array('escape'=>false),
    __('Are you sure you want to delete # %s?', $comment['Comment']['comment_id']),
   array('class' => 'btn btn-mini')
);
使用按钮

                      <?php     echo $this->Form->postLink(
                '<button class="btn btn-danger">
                     <i class="icon-trash icon-white"></i>
                 </button>',
                array(
                      'action'   => 'delete', $post['Post']['id']
                      ),
                array(
                      'class'    => 'tip',
                      'escape'   => false,
                      'confirm'  => 'Are you sure ?'
                     ));
                     ?>
试试这个:

<?php
 echo $this->Form->postLink(
                    'Delete',
                    array('controller'=>'Comments',
                      'class'=>'glyphicon glyphicon-remove','action' => 'delete',$comment['id']),
                    array('confirm' => 'Are you sure?')
 );
?> 

下面的代码将创建链接按钮,用于删除带有确认框的项目

$this->Form->postLink( 'Delete Item',
    ['action' => 'delete', 'paramId' => $item->id ],
    ['confirm' => __('Are you sure you want to delete this Item?'), 'class'=> 'btn btn-outline-danger']
)

只是你的用户体验的一点更新。您正在询问用户是否要删除具有特定ID的评论,您相信他们知道他们评论的ID是什么吗?我认为最好先问“你确定要删除下面的评论吗?”然后再添加前50个左右的字符?或者,如果这是一项管理操作,则可能包括发布它的用户的名称。稍微抬起头;-)谢谢,实际上最好不要使用注释。再次感谢!