CollectionType.php 986 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. /*
  3. * This file is part of the Sonata Project 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. namespace Sonata\AdminBundle\Form\Type;
  11. use Symfony\Component\Form\AbstractType;
  12. /**
  13. * This type wrap native `collection` form type and render `add` and `delete`
  14. * buttons in standard Symfony` collection form type.
  15. *
  16. * @author Andrej Hudec <pulzarraider@gmail.com>
  17. */
  18. class CollectionType extends AbstractType
  19. {
  20. /**
  21. * {@inheritdoc}
  22. */
  23. public function getParent()
  24. {
  25. return
  26. method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix') ?
  27. 'Symfony\Component\Form\Extension\Core\Type\CollectionType' :
  28. 'collection';
  29. }
  30. /**
  31. * {@inheritdoc}
  32. */
  33. public function getName()
  34. {
  35. return 'sonata_type_native_collection';
  36. }
  37. }