src/Form/ContactForm.php line 20

Open in your IDE?
  1. <?php
  2. /*
  3.  * Author: Dominik Piekarski <code@dompie.de>
  4.  * Created at: 2021/07/01 11:08
  5.  */
  6. declare(strict_types=1);
  7. namespace App\Form;
  8. use App\Dto\ContactFormData;
  9. use Symfony\Component\Form\AbstractType;
  10. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  11. use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  12. use Symfony\Component\Form\Extension\Core\Type\TelType;
  13. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  14. use Symfony\Component\Form\Extension\Core\Type\TextType;
  15. use Symfony\Component\Form\FormBuilderInterface;
  16. use Symfony\Component\OptionsResolver\OptionsResolver;
  17. class ContactForm extends AbstractType
  18. {
  19.     public function buildForm(FormBuilderInterface $builder, array $options)
  20.     {
  21.         $builder->add('firstName'TextType::class, [
  22.             'label' => 'Vorname*',
  23.             'attr' => [
  24.                 'maxlength' => 50,
  25.             ],
  26.         ])->add('lastName'TextType::class, [
  27.             'label' => 'Nachname',
  28.             'required' => false,
  29.             'attr' => [
  30.                 'maxlength' => 50,
  31.             ],
  32.         ])->add('email'EmailType::class, [
  33.             'label' => 'E-Mail*',
  34.         ])->add('phone'TelType::class, [
  35.             'label' => 'Telefon',
  36.             'required' => false,
  37.         ])->add('webmId'TextType::class, [
  38.             'label' => 'Webmaster ID',
  39.             'required' => false,
  40.         ])->add('topic'TextType::class, [
  41.             'label' => 'Thema/Betreff*',
  42.             'attr' => [
  43.                 'maxlength' => 100,
  44.             ],
  45.         ])->add('message'TextareaType::class, [
  46.             'label' => 'Nachricht*',
  47.         ]);
  48.         $builder->add('info'TextType::class, [
  49.             'label' => false,
  50.             'required' => false,
  51.             'disabled' => true,
  52.             'data' => '*Die mit Sternchen markierten Felder müssen ausgefüllt werden.',
  53.             'mapped' => false,
  54.         ])->add('submit'SubmitType::class, [
  55.             'label' => 'Absenden',
  56.         ]);
  57.     }
  58.     public function configureOptions(OptionsResolver $resolver)
  59.     {
  60.         $resolver->setDefaults([
  61.             'data_class' => ContactFormData::class
  62.         ]);
  63.     }
  64. }