Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Support for input Form/Type with DataTransformer #118

kornel-kedzierski opened this Issue Dec 14, 2012 · 4 comments


None yet
5 participants

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


pylebecq commented Mar 8, 2013

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


willdurand commented Mar 17, 2013

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

odoucet commented Dec 2, 2013

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