<?php

namespace AppBundle\Form;

use Doctrine\Common\Collections\Collection;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use AppBundle\Form\StDateType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\Choice;
use Symfony\Component\Validator\Constraints\NotNull;

class FewoSeasonType extends AbstractType
{
    public static $WEEKDAY_CHOICES = [
        'beliebig' => NULL,
        'Sonntag' => 0,
        'Montag' => 1,
        'Dienstag' => 2,
        'Mittwoch' => 3,
        'Donnerstag' => 4,
        'Freitag' => 5,
        'Samstag' => 6,
    ];

    /**
     * {@inheritdoc}
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('name')
            ->add('fromDate', StDateType::class, [
                //options
            ])
            ->add('toDate', StDateType::class, [
                //options
            ])
            ->add('minimumStay', TextType::class, [

            ])
            ->add('description')
            ->add('onlyWeekday', ChoiceType::class, [
                'choices' => self::$WEEKDAY_CHOICES,
                'constraints' => [
                    new Choice(['choices' => self::$WEEKDAY_CHOICES])
                ]
            ])
        ;
    }
    
    /**
     * {@inheritdoc}
     */
    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults(array(
            'data_class' => 'AppBundle\Entity\FewoSeason'
        ));
    }

    /**
     * {@inheritdoc}
     */
    public function getBlockPrefix()
    {
        return 'appbundle_fewoseason';
    }


}
