CakePHP delete confirmation

本小妞迷上赌 提交于 2020-01-03 05:04:30

问题


I have problem with Cake PHP delete javascript confirmation dialog.

I am using this code:

<td><?php echo $this->Html->link('Delete',
                                        array('controller' => 'RealEstate', 'action' => 'delete',$r['RealEstate']['id']),
                                        array('onclick'=>'return confirm(\"Are you sure?\");'))?> </td>

and this produce html:

<td><a onclick='return confirm(\"Are you sure?\");' href="/cake1/RealEstate/delete/65">Delete</a> </td>

as you can see this produce wrong Html.

How to fix this ?

FIXED: Problem was in back slashes \"Are you sure?\", just removed \ and this works well "Are you sure?"


回答1:


Try this

<?php 
     echo $this->Html->link('',array('controller'=>'Mycont','action'=>'deletepic',$id),
          array('confirm'=>'Are you sure you want to delete the image?'));
?>



回答2:


try this

 echo $this->Form->postLink(__('Delete'), array(
                               'controller'=>'RealEstate',
                               'action' => 'delete',
                                $r['RealEstate']['id']),
                                null, 
                                __('Are you sure you want to delete # %s?', 
                                $r['RealEstate']['id'])
 ); 



回答3:


FIXED: Problem was in back slashes \"Are you sure?\", just removed \ and this works well "Are you sure?"



来源:https://stackoverflow.com/questions/22519966/cakephp-delete-confirmation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!