src/Form/ContactoFormType.php line 17

Open in your IDE?
  1. <?php
  2. // src/Form/ContactFormType.php
  3. namespace App\Form;
  4. use App\Entity\TCodpos;
  5. use Symfony\Component\Form\AbstractType;
  6. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  7. use Symfony\Component\Form\Extension\Core\Type\TextType;
  8. use Symfony\Component\Form\FormBuilderInterface;
  9. use Symfony\Component\Form\FormEvent;
  10. use Symfony\Component\Form\FormEvents;
  11. use Symfony\Component\Form\FormInterface;
  12. class ContactoFormType extends AbstractType
  13. {
  14.     public function buildForm(FormBuilderInterface $builder, array $options)
  15.     {
  16.         $builder->addEventListener(FormEvents::PRE_SET_DATA, array($this'onPreSetData'));
  17.     }
  18.     function onPreSetData(FormEvent $event)
  19.     {
  20.         $form $event->getForm();
  21.         $this->addElements($form);
  22.     }
  23.     public function addElements(FormInterface $form){
  24.         $form
  25.             ->add('name'TextType::class, ['label' => 'Nombre','attr' => ['class' =>'form-control']])
  26.             ->add('email'EmailType::class, ['label' => 'Email','attr' => ['class' =>'form-control']])
  27.             ->add('phone'TextType::class, ['label' => 'TelĂ©fono de contacto','attr' => ['class' =>'form-control']]);
  28.     }
  29. }