Forked from adrienbrault/CollectionTypeExtension.php
Created
February 6, 2014 12:03
-
-
Save peterrehm/8842859 to your computer and use it in GitHub Desktop.
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'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment