<?php
namespace App\Form\Type;
use App\Controller\CouponController;
use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class ExpiredAtType extends DateTimeType
{
public function configureOptions(OptionsResolver $resolver)
{
// Set the defaults from the DateTimeType we're extending from
parent::configureOptions($resolver);
}
public function buildForm(FormBuilderInterface $builder, array $options)
{
$data = new \DateTime('now');
$options['years'] = range($data->format('Y'), $data->format('Y') + 5);
if (CouponController::$IS_NEW) {
$options['months'] = range(1,12);
$options['days'] = range($data->format('d'), $data->format('t'));
}
parent::buildForm($builder, $options); // TODO: Change the autogenerated stub
}
}