【发布时间】:2014-03-05 08:52:08
【问题描述】:
我正在使用 CakePHP 2.x。当我提交编辑表单时,它不适用于以下代码:
if ($this->request->is(array('post'))) {
...
if ($this->User->save($this->request->data)) {
...
} else {
...
}
} else {
...
}
但它适用于以下代码:
if ($this->request->is(array('post','put'))) { //change made here
...
if ($this->User->save($this->request->data)) {
...
} else {
...
}
} else {
...
}
但我希望我的代码仅适用于第一个代码。如果您有任何解决方案,请帮助我。
编辑: 请注意,当我们每次使用 CakePHP 创建一个隐藏的输入变量名称 _method 时,它的值设置为 POST 在添加表单和 PUT在编辑表格上。 CakePHP 请求处理程序使用 _method 变量,而不是表单类型属性。
【问题讨论】: