@@ -55,8 +55,18 @@ public function toString() {
55
55
* or tie plugins into a main application. requestAction can be used to return rendered views
56
56
* or fetch the return value from controller actions.
57
57
*
58
- * @param mixed $url String or array-based url.
59
- * @param array $extra if array includes the key "return" it sets the AutoRender to true.
58
+ * Under the hood this method uses Router::reverse() to convert the $url parmeter into a string
59
+ * URL. You should use URL formats that are compatible with Router::reverse()
60
+ *
61
+ * #### Passing POST and GET data
62
+ *
63
+ * POST and GET data can be simulated in requestAction. Use `$extra['url']` for
64
+ * GET data. The `$extra['data']` parameter allows POST data simulation.
65
+ *
66
+ * @param mixed $url String or array-based url. Unlike other url arrays in CakePHP, this
67
+ * url will not automatically handle passed and named arguments in the $url paramenter.
68
+ * @param array $extra if array includes the key "return" it sets the AutoRender to true. Can
69
+ * also be used to submit GET/POST data, and named/passed arguments.
60
70
* @return mixed Boolean true or false on success/failure, or contents
61
71
* of rendered action if 'return' is set in $extra.
62
72
*/
@@ -74,16 +84,18 @@ public function requestAction($url, $extra = array()) {
74
84
$ extra ['url ' ] = array ();
75
85
}
76
86
$ extra = array_merge (array ('autoRender ' => 0 , 'return ' => 1 , 'bare ' => 1 , 'requested ' => 1 ), $ extra );
87
+ $ data = isset ($ extra ['data ' ]) ? $ extra ['data ' ] : null ;
88
+ unset($ extra ['data ' ]);
77
89
78
90
if (is_string ($ url )) {
79
91
$ request = new CakeRequest ($ url );
80
92
} elseif (is_array ($ url )) {
81
93
$ params = $ url + array ('pass ' => array (), 'named ' => array (), 'base ' => false );
82
94
$ params = array_merge ($ params , $ extra );
83
95
$ request = new CakeRequest (Router::reverse ($ params ), false );
84
- if ( isset ( $ params [ ' data ' ])) {
85
- $ request -> data = $ params [ ' data ' ];
86
- }
96
+ }
97
+ if ( isset ( $ data)) {
98
+ $ request -> data = $ data ;
87
99
}
88
100
89
101
$ dispatcher = new Dispatcher ();
0 commit comments