CollectionType.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /*
  3. * This file is part of the Sonata package.
  4. *
  5. * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. *
  10. */
  11. namespace Sonata\AdminBundle\Form\Type;
  12. use Symfony\Component\Form\AbstractType;
  13. use Symfony\Component\Form\FormBuilder;
  14. use Sonata\AdminBundle\Form\EventListener\ResizeFormListener;
  15. class CollectionType extends AbstractType
  16. {
  17. public function buildForm(FormBuilder $builder, array $options)
  18. {
  19. $listener = new ResizeFormListener(
  20. $builder->getFormFactory(),
  21. $options['type'],
  22. $options['type_options'],
  23. $options['modifiable']
  24. );
  25. $builder->addEventSubscriber($listener);
  26. }
  27. public function getDefaultOptions(array $options)
  28. {
  29. return array(
  30. 'modifiable' => false,
  31. 'type' => 'text',
  32. 'type_options' => array()
  33. );
  34. }
  35. public function getName()
  36. {
  37. return 'sonata_type_collection';
  38. }
  39. }