-
-
Save jumika/e2f0a5b3d4faf277307a to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
use Symfony\Component\Form\AbstractTypeExtension; | |
use Symfony\Component\OptionsResolver\OptionsResolverInterface; | |
use Symfony\Component\Form\FormBuilderInterface; | |
class CollectionPrototypeDataTypeExtension extends AbstractTypeExtension { | |
public function buildForm(FormBuilderInterface $builder, array $options) { | |
parent::buildForm($builder, $options); | |
if(($prototypeFormBuilder = $builder->getAttribute('prototype')) && isset($options['prototype_data'])) { | |
$prototypeFormBuilder->setData($options['prototype_data']); | |
} | |
} | |
public function setDefaultOptions(OptionsResolverInterface $resolver) { | |
$resolver->setOptional(array('prototype_data')); | |
} | |
public function getExtendedType() { | |
return 'collection'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment