第一个postLink()不创建表单 [英] First postLink() doesn't create form

查看:185
本文介绍了第一个postLink()不创建表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用已经存入CRUD 的代码,我有以下用于删除项目的代码:

Using code that has been baked into CRUD, I have the following code for deleting an item:

<?php echo $this->Form->postLink(__('Delete'), array('controller'=>'attachments', 'action' => 'delete', $attachment['Attachment']['id']), null, __('Are you sure you want to delete "%s?"', $attachment['Attachment']['name'])); ?>

问题是它包裹在FORM标记最终发生的是 Cake不包括postLink将提交的Form

The problem is that it lies wrapped in a FORM tag, and so what ends up happening is Cake doesn't include the Form that the postLink would submit.

有没有另一种方式仍然坚持Cake的基础设施的完整性,即使我增加安全设置也能工作?可能需要一个链接到/ attachment / delete / id,但由于某种原因烘焙选择创建一个表单并发布,而不是创建一个链接,所以我想有这样的原因,如果是,我想坚持原因。

Is there another way that still holds true to the integrity of Cake's infrastructure that would work even when I increase the security settings? Probably needs to be a link to /attachment/delete/id, but baking for some reason chose to create a form and post it vs. creating a link, so I figured there was a reason for that and if so I want to uphold that reason.

推荐答案

您可能没有阅读doc方块中关于此方法的警告
http://book.cakephp.org/2.0/en /core-libraries/helpers/form.html#FormHelper::postLink

You probably didn't read the warnings in the doc block regarding this method (http://book.cakephp.org/2.0/en/core-libraries/helpers/form.html#FormHelper::postLink)


此方法创建< form> 元素。因此,不要在现有表单中使用此方法。
相反,您应该使用 FormHelper :: submit()添加一个提交按钮

This method creates a <form> element. So do not use this method inside an existing form. Instead you should add a submit button using FormHelper::submit()


$ b b

所以不要这样做。您需要写入缓冲区并稍后输出(请参阅此封闭的PR )。

这篇关于第一个postLink()不创建表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆