Created
January 29, 2013 17:43
-
-
Save adrienbrault/4666086 to your computer and use it in GitHub Desktop.
Workaround to get the same feature as in https://github.com/symfony/symfony/pull/6910
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Incenteev\Bundle\Form\Extension; | |
use Symfony\Component\Form\AbstractTypeExtension; | |
use Symfony\Component\Form\FormBuilderInterface; | |
use Symfony\Component\OptionsResolver\OptionsResolverInterface; | |
/** | |
* @author Adrien Brault <[email protected]> | |
*/ | |
class CollectionTypeExtension extends AbstractTypeExtension | |
{ | |
/** | |
* {@inheritdoc} | |
*/ | |
public function buildForm(FormBuilderInterface $builder, array $options) | |
{ | |
if (null !== ($prototypeFormBuilder = $builder->getAttribute('prototype'))) { | |
/** @var $prototypeFormBuilder FormBuilderInterface */ | |
$prototypeFormBuilder->setData($options['prototype_data']); | |
} | |
} | |
/** | |
* {@inheritdoc} | |
*/ | |
public function setDefaultOptions(OptionsResolverInterface $resolver) | |
{ | |
$resolver->setDefaults(array( | |
'prototype_data' => null, | |
)); | |
} | |
/** | |
* {@inheritdoc} | |
*/ | |
public function getExtendedType() | |
{ | |
return 'collection'; | |
} | |
} |
Thanks! Works perfectly!
Thanks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks so much for this :)