src/AppBundle/Form/Customer/ContactRequestType.php line 49

Open in your IDE?
  1. <?php
  2. namespace AppBundle\Form\Customer;
  3. use AppBundle\Entity\Customer\ContactRequestTime;
  4. use Symfony\Bridge\Doctrine\Form\Type\EntityType;
  5. use Symfony\Component\Form\AbstractType;
  6. use Symfony\Component\Form\Extension\Core\Type\DateType;
  7. use Symfony\Component\Form\FormBuilderInterface;
  8. use Symfony\Component\OptionsResolver\OptionsResolver;
  9. use Symfony\Component\Validator\Constraints\Length;
  10. use Symfony\Component\Validator\Constraints\NotBlank;
  11. class ContactRequestType extends AbstractType
  12. {
  13.     /**
  14.      * {@inheritdoc}
  15.      */
  16.     public function buildForm(FormBuilderInterface $builder, array $options)
  17.     {
  18.         $builder
  19.             ->add('name'null, [
  20.                 'label' => false,
  21.                 'attr' => ['class'=> 'form-control input-sm''placeholder' => 'ImiÄ™ i nazwisko''required' => true],
  22.                 'translation_domain' => false,
  23.                 'constraints' => [
  24.                     new NotBlank(),
  25.                     new Length(array('min' => 3)),
  26.                 ]
  27.             ])
  28.             ->add('phone'null, [
  29.                 'label' => false,
  30.                 'attr' => ['class'=> 'form-control input-sm''placeholder' => 'Numer telefonu''required' => true],
  31.                 'translation_domain' => false,
  32.                 'constraints' => [
  33.                     new NotBlank(),
  34.                     new Length(array('min' => 9)),
  35.                 ]
  36.             ])
  37.             ->add('contactRequestDate'DateType::class, [
  38.                 'label' => 'Data',
  39.                 'widget' => 'single_text',
  40.                 'html5' => false,
  41.                 'attr' => ['class' => 'rozmowa_date form-control input-sm'],
  42.                 'translation_domain' => false,
  43.             ])
  44.             ->add('contactRequestTime'EntityType::class, [
  45.                 'class' => ContactRequestTime::class,
  46.                 'choice_label' => function ($range) {
  47.                     /** @var $range ContactRequestTime */
  48.                     return $range->getDisplayName();
  49.                 },
  50.                 'attr' => ['class' => 'form-control input-sm'],
  51.                 'translation_domain' => false
  52.             ])
  53.         ;
  54.     }
  55.     /**
  56.      * {@inheritdoc}
  57.      */
  58.     public function configureOptions(OptionsResolver $resolver)
  59.     {
  60.         $resolver->setDefaults(array(
  61.             'data_class' => 'AppBundle\Entity\Customer\ContactRequest'
  62.         ));
  63.     }
  64.     /**
  65.      * {@inheritdoc}
  66.      */
  67.     public function getBlockPrefix()
  68.     {
  69.         return 'appbundle_customer_contactrequest';
  70.     }
  71. }