<?php

namespace Lc\ShopBundle\Form\Backend\ReductionCommon;

use Doctrine\ORM\EntityManagerInterface;

use Lc\ShopBundle\Context\ReductionCartInterface;
use Lc\ShopBundle\Context\ReductionCatalogInterface;
use Lc\ShopBundle\Context\UserInterface;
use Lc\ShopBundle\Repository\GroupUserRepository;
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\NumberType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver;

class ValueType extends AbstractType
{
        public function buildForm(FormBuilderInterface $builder, array $options)
        {
                $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {
                        $builder = $event->getForm()->getParent();

                        $builder->add('value', NumberType::class, [
                                'required' => false
                        ]);
                });
        }

        public function configureOptions(OptionsResolver $resolver)
        {
                /*$resolver->setDefaults([
                        'data_class' => $this->em->getClassMetadata(ReductionCatalogInterface::class)->getName(),
                ]);*/
        }
}
