如何在Sonata Admin Bundle configureFormFields中使用现有的Symfony FormType? [英] How to use existing Symfony FormType in Sonata Admin Bundle configureFormFields?

查看:43
本文介绍了如何在Sonata Admin Bundle configureFormFields中使用现有的Symfony FormType?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SonataAdminBundle提供了一种方法 configureFormFields .

SonataAdminBundle gives a method configureFormFields when you extend the Admin class.

该方法采用一个 FormMapper 类.

对于我为其创建此类的实体,我已经以典型的Symfony方式构建了 FormType 类.

For the entity that I have created this class for, I have already built a FormType class in the typical Symfony fashion.

如何使用该类,而不必再次使用 FormMapper 定义表单属性?

How can I use that class instead of having to define the form properties again using the FormMapper?

推荐答案

类似:

public function configureFormFields(FormMapper $formMapper)
{        
    $form = new ReviewFormType();
    $form->buildForm($formMapper->getFormBuilder(),array());
}

这篇关于如何在Sonata Admin Bundle configureFormFields中使用现有的Symfony FormType?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆