src/AppBundle/Form/Customer/ContactFormType.php line 16

Open in your IDE?
  1. <?php
  2. namespace AppBundle\Form\Customer;
  3. use AppBundle\Entity\Customer\ContactForm;
  4. use Captcha\Bundle\CaptchaBundle\Form\Type\CaptchaType;
  5. use Symfony\Component\Form\AbstractType;
  6. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  7. use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  8. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  9. use Symfony\Component\Form\FormBuilderInterface;
  10. use Symfony\Component\OptionsResolver\OptionsResolver;
  11. use Symfony\Component\Validator\Constraints\Length;
  12. use Symfony\Component\Validator\Constraints\NotBlank;
  13. class ContactFormType extends AbstractType
  14. {
  15.     /**
  16.      * {@inheritdoc}
  17.      */
  18.     public function buildForm(FormBuilderInterface $builder, array $options)
  19.     {
  20.         $builder
  21.             ->add('contactRequest'ContactFormRequestType::class, ['label' => false])
  22.             ->add('reason'ChoiceType::class, [
  23.                 'choices'  => array(
  24.                     ContactForm::REASON_1 => '1',
  25.                     ContactForm::REASON_2 => '2',
  26.                     ContactForm::REASON_3 => '3',
  27.                     ContactForm::REASON_4 => '4',
  28.                     ContactForm::REASON_5 => '5',
  29.                     ContactForm::REASON_6 => '6'
  30.                 ),
  31.                 'label' => false,
  32.                 'attr' => ['class'=> 'form-control form-control-sm'],
  33.                 'translation_domain' => false
  34.             ])
  35.             ->add('message'TextareaType::class, [
  36.                 'label' => false,
  37.                 'attr' => ['class'=> 'form-control form-control-sm''placeholder' => 'Treść wiadomości''rows' => 5],
  38.                 'translation_domain' => false,
  39.                 'constraints' => [
  40.                     new NotBlank(),
  41.                     new Length(array('min' => 3)),
  42.                 ]
  43.             ])
  44.         ;
  45.     }/**
  46.      * {@inheritdoc}
  47.      */
  48.     public function configureOptions(OptionsResolver $resolver)
  49.     {
  50.         $resolver->setDefaults(array(
  51.             'data_class' => 'AppBundle\Entity\Customer\ContactForm'
  52.         ));
  53.     }
  54.     /**
  55.      * {@inheritdoc}
  56.      */
  57.     public function getBlockPrefix()
  58.     {
  59.         return 'appbundle_customer_contactform';
  60.     }
  61. }