DateRangeType.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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\FormTypeInterface;
  14. use Symfony\Component\Form\FormBuilder;
  15. use Symfony\Component\Translation\TranslatorInterface;
  16. class DateRangeType extends AbstractType
  17. {
  18. protected $translator;
  19. public function __construct(TranslatorInterface $translator)
  20. {
  21. $this->translator = $translator;
  22. }
  23. public function buildForm(FormBuilder $builder, array $options)
  24. {
  25. $builder->add('start', 'date', array_merge(array('required' => false), $options['field_options']));
  26. $builder->add('end', 'date', array_merge(array('required' => false), $options['field_options']));
  27. }
  28. public function getDefaultOptions(array $options)
  29. {
  30. return $options;
  31. }
  32. public function getName()
  33. {
  34. return 'sonata_type_date_range';
  35. }
  36. }