src/Form/ContactType.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use Symfony\Component\Form\AbstractType;
  4. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  5. use Symfony\Component\Form\Extension\Core\Type\TextType;
  6. use Symfony\Component\Form\FormBuilderInterface;
  7. use Symfony\Component\OptionsResolver\OptionsResolver;
  8. use Symfony\Component\Validator\Constraints\NotBlank;
  9. class ContactType extends AbstractType
  10. {
  11.     /**
  12.      * {@inheritdoc}
  13.      */
  14.     public function buildForm(FormBuilderInterface $builder, array $options)
  15.     {
  16.         $builder
  17.             ->add('name'TextType::class, [
  18.                 "label" => "contact.name",
  19.                 "required"=>true,
  20.                 'constraints' => [new NotBlank()]
  21.             ])
  22.             ->add('email'TextType::class, [
  23.                 "label" => "contact.email",
  24.                 "required"=>true,
  25.                 'constraints' => [new NotBlank()]
  26.             ])
  27.             ->add('message'TextareaType::class, [
  28.                 "label" => "contact.message",
  29.                 "required"=>true,
  30.                 'constraints' => [new NotBlank()]
  31.             ]);
  32.     }
  33.     /**
  34.      * {@inheritdoc}
  35.      */
  36.     public function configureOptions(OptionsResolver $resolver)
  37.     {
  38.         $resolver->setDefaults(array(
  39.             'translation_domain' => 'messages',
  40.             'data_class' => 'App\Entity\Contact'
  41.         ));
  42.     }
  43.     /**
  44.      * {@inheritdoc}
  45.      */
  46.     public function getBlockPrefix()
  47.     {
  48.         return 'contactbundle_contact';
  49.     }
  50. }