Symfony : Can I return null from Type / Form?
<p>I have an entity form with Symfony :</p>

<pre><code>class MyType extends AbstractType
{

    /**
     * @param FormBuilderInterface $builder
     * @param array $options
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
       ...
    }

    /**
     * @param OptionsResolverInterface $resolver
     */
    public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
        $resolver-&gt;setDefaults(array(
            'data_class' =&gt; 'LogicielBundle\Entity\FichierGroup',
            'intention' =&gt; $this-&gt;getName() . '_token'
        ));
    }
</code></pre>

<p>But in POST_SUBMIT event, I want to return null (no entity).
I tested this but not working :</p>

<pre><code>    $builder-&gt;addEventListener(FormEvents::POST_SUBMIT, function(FormEvent $event) {
        .... my condition ...
        $event-&gt;setData(null);
    });
</code></pre>

<p>Can you help me ? Thanks :)</p>