添加表单请求类型伪装支持 默认变量为 _method

This commit is contained in:
thinkphp
2016-05-30 21:34:48 +08:00
parent 07683eea75
commit 69fa69dc3b
2 changed files with 8 additions and 1 deletions

View File

@@ -83,6 +83,8 @@ return [
'url_controller_convert' => true,
// 是否自动转换URL中的操作名
'url_action_convert' => true,
// 表单请求类型伪装变量
'method_var' => '_method',
// +----------------------------------------------------------------------
// | 模板引擎设置

View File

@@ -417,7 +417,12 @@ class Request
$this->method = $method;
return;
} elseif (!$this->method) {
$this->method = IS_CLI ? 'GET' : (isset($this->server['REQUEST_METHOD']) ? $this->server['REQUEST_METHOD'] : $_SERVER['REQUEST_METHOD']);
$mask = $this->param(Config::get('method_var'));
if ($mask) {
$this->method = $mask;
} else {
$this->method = IS_CLI ? 'GET' : (isset($this->server['REQUEST_METHOD']) ? $this->server['REQUEST_METHOD'] : $_SERVER['REQUEST_METHOD']);
}
}
return $this->method;
}