Forms 如何为symfony3发送FormType中的参数?

Forms 如何为symfony3发送FormType中的参数?,forms,symfony,Forms,Symfony,使用symfony2,当我从控制器创建表单时,我能够发送参数: $form = $this->createForm( new articleType( $localedefault, $this->get('request')->getLocale(), $depotCat, $this->get('security.context') ), $article ); 我从我的Arti

使用symfony2,当我从控制器创建表单时,我能够发送参数:

$form = $this->createForm(
    new articleType(
        $localedefault,
        $this->get('request')->getLocale(),
        $depotCat,
        $this->get('security.context')
    ),
    $article
);
我从我的
ArticleType
的构造函数中恢复了这些参数

对于symfony3,我将以下内容:

$form = $this->createForm(
    ArticleType::class,
    $article,
    array(
        $localedefault,
        $request->getLocale(),
        $depotCat,
        $this->get('security.authorization_checker')
    )
);

但是这个方法不起作用。

在类中使用
configureOptions
,然后:
setDefault('myOption',[])

实例化时:

$form = $this->createForm(
    ArticleType::class,
    $article,
    array(
        'myOption'=>array(...)
    )
);

然后在
buildForm
中,您将在
选项
数组中有一个正确的键。

请格式化您的代码,因为它有助于可读性,并且更有可能吸引答案。我已相应地编辑了您的问题。好的,对不起,下次在我的课堂上我会做得更好,我如何在函数configureOptions中添加此选项。此函数仅接受“optionResolver”您是否根据文档尝试在
ArticleType
课堂中实现了配置选项?我没有发布完整的工作代码。看看文档,一切看起来都很合理。很好,我理解它的工作原理。非常感谢你的帮助