Making it so all POST parameters are available on $this->data inside the request. This makes one fewer place POST data

is found.  $this->params['form'] is still around as well for Backwards compatibility, but is not recommended for use
going forward.
This commit is contained in:
mark_story 2011-04-28 22:42:50 -04:00
parent 60ee04a0fb
commit 975f74bb44
2 changed files with 17 additions and 5 deletions

View file

@ -133,6 +133,8 @@ class CakeRequest implements ArrayAccess {
/**
* process the post data and set what is there into the object.
* The raw post is available at $this->params['form'], while a lightly processed
* version is available at $this->data
*
* @return void
*/
@ -150,11 +152,12 @@ class CakeRequest implements ArrayAccess {
} else {
$_ENV['REQUEST_METHOD'] = $this->params['form']['_method'];
}
unset($this->params['form']['_method']);
}
if (isset($this->params['form']['data'])) {
$this->data = $this->params['form']['data'];
unset($this->params['form']['data']);
$this->data = $this->params['form'];
if (isset($this->data['data'])) {
$data = $this->data['data'];
unset($this->data['data']);
$this->data = Set::merge($this->data, $data);
}
}
@ -533,6 +536,14 @@ class CakeRequest implements ArrayAccess {
/**
* Get the HTTP method used for this request.
* There are a few ways to specify a method.
*
* - If your client supports it you can use native HTTP methods.
* - You can set the HTTP-X-Method-Override header.
* - You can submit an input with the name `_method`
*
* Any of these 3 approaches can be used to set the HTTP method used
* by CakePHP internally, and will effect the result of this method.
*
* @return string The name of the HTTP method used.
*/

View file

@ -160,7 +160,8 @@ class CakeRequestTestCase extends CakeTestCase {
$_POST = array('one' => 1, 'two' => 'three');
$request = new CakeRequest('some/path');
$this->assertEqual($request->params['form'], $_POST);
$this->assertEquals($_POST, $request->params['form']);
$this->assertEquals($_POST, $request->data);
}
/**