Skip to content

Instantly share code, notes, and snippets.

@mhlavac
Created May 24, 2016 12:30
Show Gist options
  • Save mhlavac/adafc2ce5fd5fedcea77ffbe79f30430 to your computer and use it in GitHub Desktop.
Save mhlavac/adafc2ce5fd5fedcea77ffbe79f30430 to your computer and use it in GitHub Desktop.
<?php
class UserType extends \Symfony\Component\Form\AbstractType
{
public function buildForm(\Symfony\Component\Form\FormBuilderInterface $builder, array $options)
{
$builder->add('name', CompoundType::class, [
'inherit_data' => true,
]);
$builder->addEventListener(\Symfony\Component\Form\FormEvents::POST_SET_DATA, function (\Symfony\Component\Form\FormEvent $event) {
$child = $event->getForm()->get('name');
$child->getConfig()->getEventDispatcher()->dispatch(FormEvents::POST_SET_DATA, new FormEvent($child, $event->getData()));
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment