src/Form/ContactType.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use App\Entity\Contact;
  4. use EasyCorp\Bundle\EasyAdminBundle\Field\TelephoneField;
  5. use Misd\PhoneNumberBundle\Form\Type\PhoneNumberType;
  6. use Symfony\Component\Form\AbstractType;
  7. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  8. use Symfony\Component\Form\Extension\Core\Type\IntegerType;
  9. use Symfony\Component\Form\Extension\Core\Type\TelType;
  10. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  11. use Symfony\Component\Form\Extension\Core\Type\TextType;
  12. use Symfony\Component\Form\FormBuilderInterface;
  13. use Symfony\Component\OptionsResolver\OptionsResolver;
  14. class ContactType extends AbstractType
  15. {
  16.     public function buildForm(FormBuilderInterface $builder, array $options)
  17.     {
  18.         $builder
  19.             ->add('name',TextType::class,[
  20.                 'required' => true
  21.             ])
  22.             ->add('email'EmailType::class, [
  23.                 'required' => true
  24.             ])
  25.             ->add('phone'TelType::class, [
  26.                 'required' => true,
  27.                 'label' => false
  28.             ])
  29.             ->add('subject',TextType::class, [
  30.                 'required' => true
  31.             ])
  32.             ->add('content'TextareaType::class, [
  33.                 'required' => true
  34.             ])
  35.         ;
  36.     }
  37.     public function configureOptions(OptionsResolver $resolver)
  38.     {
  39.         $resolver->setDefaults([
  40.             'data_class' => Contact::class,
  41.             'action' => '/contact/send',
  42.             'attr' => [
  43.                 'id' => 'form_contact_id'
  44.             ]
  45.         ]);
  46.     }
  47. }