src/Form/Type/ExpiredAtType.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Form\Type;
  3. use App\Controller\CouponController;
  4. use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
  5. use Symfony\Component\Form\FormBuilderInterface;
  6. use Symfony\Component\OptionsResolver\OptionsResolver;
  7. class ExpiredAtType extends DateTimeType
  8. {
  9.     public function configureOptions(OptionsResolver $resolver)
  10.     {
  11.         // Set the defaults from the DateTimeType we're extending from
  12.         parent::configureOptions($resolver);
  13.     }
  14.     public function buildForm(FormBuilderInterface $builder, array $options)
  15.     {
  16.         $data = new \DateTime('now');
  17.         $options['years'] = range($data->format('Y'), $data->format('Y') + 5);
  18.         if (CouponController::$IS_NEW) {
  19.             $options['months'] = range(1,12);
  20.             $options['days'] = range($data->format('d'), $data->format('t'));
  21.         }
  22.         parent::buildForm($builder$options); // TODO: Change the autogenerated stub
  23.     }
  24. }