Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Support for input Form/Type with DataTransformer #118

kornel-kedzierski opened this Issue · 4 comments

5 participants


Simple FormType works great, but when I add DataTransformers, docs for input becomes empty.


I can confirm that. There is also another thing : if an option is required but does not have a default value.


Tagged as "enhancement", feel free to work on it :)


Small work on this task : doc is empty because the formType cannot be created. This is because when you use dataTransformers, you have to extend setDefaultOptions() and require an option 'em' as ObjectManager.
NelmioDocType does not pass it at creation, and silently dropped the error (better have an empty doc for this form, than no doc at all).

So this works:

    public function setDefaultOptions(OptionsResolverInterface $resolver)
            'data_class' => 'My\APIBundle\Entity\User',
            'csrf_protection'   => false,

And this does not :

    public function setDefaultOptions(OptionsResolverInterface $resolver)
            'data_class' => 'My\APIBundle\Entity\User',
            'csrf_protection'   => false,
                'em' => 'Doctrine\Common\Persistence\ObjectManager',

So to support DataTransformer, I think we need to modify Parser/FormTypeParser.php


Hi guys, I've faced the same problem. But looking at how ApiDoc bundle works for few minutes I've found a solution for my case! Here it is:
1. First, define your form as service, it is pretty easy, suppose it is "form_alias_you_defined"
2. Inject needed services to form (ex. EntityManager)
3. Use your form name in ApiDoc instead of form class like this:

* ...
* input = "form_alias_you_defined"

Also don't forget to read official documentation with usefull tips, like passing method (GET, POST, etc).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.