Cakephp 正在将`new\Cake\View\ViewBuilder()`连接到主`\Cake\Http\ServerRequest`

Cakephp 正在将`new\Cake\View\ViewBuilder()`连接到主`\Cake\Http\ServerRequest`,cakephp,cakephp-3.0,Cakephp,Cakephp 3.0,我正在通过一个新的、独立的ViewBuilder将视图模板渲染为变量 $builder = new \Cake\View\ViewBuilder(); $builder->setLayout('my_layout'); $builder->setTemplate('my_template'); 上面的模板包含一个表单 echo $this->Form->create(null, array( 'type' => 'POST', 'url' =>

我正在通过一个新的、独立的
ViewBuilder
将视图模板渲染为变量

$builder = new \Cake\View\ViewBuilder();
$builder->setLayout('my_layout');
$builder->setTemplate('my_template');
上面的模板包含一个表单

echo $this->Form->create(null, array(
    'type' => 'POST',
    'url' => '/',
)).PHP_EOL;
$this->Form->unlockField('my_input');
echo $this->Form->end();
提交时,会导致以下错误

在请求数据中找不到“\u令牌”

据我所知,没有添加令牌是因为
FormHelper
接收
false
,这是因为这个新的
ViewBuilder
没有连接到应用程序操作的实际请求


有没有办法将我新的
ViewBuilder
连接到应用程序的主
Cake\Http\ServerRequest
。是否确实需要创建新的视图生成器,而不仅仅是在普通视图的模板中渲染单元或元素?“你现在是怎么理解的?”阿霍夫纳,就是这样,谢谢!必须将
$this->getRequest()
作为第二个参数传递给。您是对的,这需要重构,但无论如何都必须使其在当前状态下工作。你介意把这个贴出来作为回答吗?这样我就可以接受它,结束这个问题。