Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
43 lines (37 sloc) 1 KB
<?php
namespace SMTC\MainBundle\Form\Extension;
use Symfony\Component\Form\AbstractTypeExtension;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
/**
* @author Adrien Brault <adrien.brault@gmail.com>
*/
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';
}
}