CollectionType.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. * @todo Remove when dropping Symfony <2.8 support
  34. */
  35. public function getName()
  36. {
  37. return $this->getBlockPrefix();
  38. }
  39. /**
  40. * {@inheritdoc}
  41. */
  42. public function getBlockPrefix()
  43. {
  44. return 'sonata_type_native_collection';
  45. }
  46. }