Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Support for input Form/Type with DataTransformer #118

Open
kornel-kedzierski opened this Issue · 3 comments

4 participants

kornel-kedzierski Pierre-Yves Lebecq William Durand Olivier Doucet
kornel-kedzierski

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

Pierre-Yves Lebecq

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

William Durand
Collaborator

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

Olivier Doucet

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)
    {
        $resolver->setDefaults(array(
            'data_class' => 'My\APIBundle\Entity\User',
            'csrf_protection'   => false,
        ));
    }

And this does not :

    public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
        $resolver->setDefaults(array(
            'data_class' => 'My\APIBundle\Entity\User',
            'csrf_protection'   => false,
        ))
        ->setRequired(array(
                'em'
        ))
        ->setAllowedTypes(array(
                'em' => 'Doctrine\Common\Persistence\ObjectManager',
            ))
        ;
    }

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

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.