2017-03-16 68 views
0

如何向此代码添加类?CakePHP 3.0 - 发布链接 - 添加一个类删除警报确认功能

$this->Form->postLink(
    __('Delete'), 
    ['action' => 'delete', $user->id], 
    ['confirm' => __('Are you sure you want to delete # {0}?', $user->id)] 
) 

当我添加一个类的“确认功能”消失。

$this->Form->postLink(
    __('Delete'), 
    ['action' => 'delete', $user->id], 
    ['class' => 'btn btn-danger'], 
    ['confirm' => __('Are you sure you want to delete # {0}?', $user->id)] 
) 
+0

告诉我们在哪儿,你增加了一个类的代码。 – FrankerZ

+0

Form-> postLink(__('Delete'),['action'=>'delete',$ user-> id],['class'=>'btn btn-danger'],['confirm'= > __('你确定要删除#{0}?',$ user-> id)])?> –

回答

0

设置课前确认

['class' => 'btn btn-danger','confirm' => __('Are you sure you want to delete # {0}?', $user->id)] 
+0

我得到这个错误。 错误:语法错误,意想不到的 ''=> __( ''(T_CONSTANT_ENCAPSED_STRING),期望 ']' 文件/Applications/AMPPS/www/tanv4_cake_theme/src/Template/Users/index.ctp 行:59 –

+0

是你的类与确认? 你的榜样完整链接,中庸之道复制粘贴,并且将做的工作 回声$这个 - >形式 - > postLink( __(“删除”), [”数组'''>'删除',$ user-> id], ['class'=>'btn btn-danger','confirm'=> __('您确定要删除#{0}?' ,$ _club_user-> id)] ) – Gransfall

+0

查看代码突出显示@Gransfall You h在您的代码示例中出现语法错误,您错过了一个报价。 – ndm

1

confirmclass应在同一阵列

$this->Form->postLink(
    __('Delete'), 
    ['action' => 'delete', $user->id], 
    ['confirm' => __('Are you sure you want to delete # {0}?', $user->id),'class'=>'btn btn-danger'] 
) 
+0

是的,它们都应该在同一个数组中。 非常感谢:) –