src/Form/Einsendung/VereinsbeitragType.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Form\Einsendung;
  3. use App\Entity\Einsendung\Vereinsbeitrag;
  4. use App\Entity\Vs\Vs;
  5. use Symfony\Component\Form\AbstractType;
  6. use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
  7. use Symfony\Component\Form\Extension\Core\Type\HiddenType;
  8. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  9. use Symfony\Component\Form\Extension\Core\Type\TextType;
  10. use Symfony\Component\Form\FormBuilderInterface;
  11. use Symfony\Component\OptionsResolver\OptionsResolver;
  12. use Symfony\Component\Routing\RouterInterface;
  13. use Symfony\Component\Validator\Constraints\Length;
  14. use Symfony\Component\Validator\Constraints\NotBlank;
  15. class VereinsbeitragType extends AbstractType
  16. {
  17. public function __construct(private readonly RouterInterface $router)
  18. {
  19. }
  20. #[\Override]
  21. public function buildForm(FormBuilderInterface $builder, array $options): void
  22. {
  23. $builder
  24. ->add('titel', null, [
  25. 'required' => true,
  26. 'constraints' => [
  27. new NotBlank(),
  28. new Length(['max' => 100]),
  29. ],
  30. ])
  31. ->add('text', TextareaType::class,
  32. [
  33. 'required' => true,
  34. 'attr' => ['maxlength' => 3000, 'placeholder' => 'Max. 3000 Zeichen, inkl. Leerschläge'],
  35. 'constraints' => [
  36. new NotBlank(),
  37. new Length(['max' => 3000]),
  38. ],
  39. ]
  40. )
  41. ->add('bemerkungen', TextareaType::class,
  42. [
  43. 'required' => false,
  44. 'attr' => ['maxlength' => 1000],
  45. 'constraints' => [
  46. new Length(['max' => 1000]),
  47. ],
  48. ]
  49. )
  50. // Kontakt
  51. ->add('firma', TextType::class,
  52. [
  53. 'required' => true,
  54. 'label' => 'Vereinsname',
  55. 'attr' => ['maxlength' => 100, 'placeholder' => 'Vereinsname / Organisation'],
  56. 'constraints' => [
  57. new Length(['max' => 100]),
  58. new NotBlank(),
  59. ],
  60. ]
  61. )
  62. ->add('vorname', TextType::class,
  63. [
  64. 'required' => true,
  65. 'attr' => ['maxlength' => 100],
  66. 'constraints' => [
  67. new Length(['max' => 100]),
  68. new NotBlank(),
  69. ],
  70. ]
  71. )
  72. ->add('nachname', TextType::class,
  73. [
  74. 'required' => true,
  75. 'label' => 'Name',
  76. 'attr' => ['maxlength' => 100],
  77. 'constraints' => [
  78. new Length(['max' => 100]),
  79. new NotBlank(),
  80. ],
  81. ]
  82. )
  83. ->add('strasse', TextType::class,
  84. [
  85. 'required' => true,
  86. 'attr' => ['maxlength' => 100],
  87. 'constraints' => [
  88. new Length(['max' => 100]),
  89. new NotBlank(),
  90. ],
  91. 'label' => 'Strasse/Nr.'
  92. ]
  93. )
  94. ->add('plz', TextType::class,
  95. [
  96. 'label' => 'PLZ',
  97. 'required' => true,
  98. 'attr' => ['maxlength' => 100],
  99. 'constraints' => [
  100. new Length(['max' => 100]),
  101. new NotBlank(),
  102. ],
  103. ]
  104. )
  105. ->add('ort', TextType::class,
  106. [
  107. 'required' => true,
  108. 'attr' => ['maxlength' => 100],
  109. 'constraints' => [
  110. new Length(['max' => 100]),
  111. new NotBlank(),
  112. ],
  113. ]
  114. )
  115. ->add('telefon', TextType::class,
  116. [
  117. 'required' => true,
  118. 'attr' => ['maxlength' => 100],
  119. 'constraints' => [
  120. new Length(['max' => 100]),
  121. new NotBlank(),
  122. ],
  123. ]
  124. )
  125. ->add('email', TextType::class,
  126. [
  127. 'label' => 'E-Mail',
  128. 'required' => true,
  129. 'attr' => ['maxlength' => 100],
  130. 'constraints' => [
  131. new Length(['max' => 100]),
  132. new NotBlank(),
  133. ],
  134. ]
  135. )
  136. // Image
  137. ->add('imageFilepath', HiddenType::class, ['label' => 'Bild 1', 'required' => false, 'mapped' => true, 'help' => 'max. 5 MB'])
  138. ->add('imageAlt', TextType::class, ['label' => 'Bild Alt', 'required' => false, 'mapped' => false, 'attr' => ['placeholder' => 'Bildbeschreibung (alt-Tag)']])
  139. ->add('imageCaption', TextType::class, ['label' => 'Bild Caption', 'mapped' => false, 'help' => 'Bild wird automatisch auf '.Vs::MAX_WIDTH_VSIMAGE.'px Breite runtergerechnet falls grösser.', 'required' => false, 'attr' => ['placeholder' => 'Bildlegende (figcaption-Tag)']])
  140. ->add('imageFilepath2', HiddenType::class, ['label' => 'Bild 2', 'required' => false, 'mapped' => true, 'help' => 'max. 5 MB'])
  141. ->add('imageAlt2', TextType::class, ['label' => 'Bild Alt', 'required' => false, 'mapped' => false, 'attr' => ['placeholder' => 'Bildbeschreibung (alt-Tag)']])
  142. ->add('imageCaption2', TextType::class, ['label' => 'Bild Caption', 'mapped' => false, 'help' => 'Bild wird automatisch auf '.Vs::MAX_WIDTH_VSIMAGE.'px Breite runtergerechnet falls grösser.', 'required' => false, 'attr' => ['placeholder' => 'Bildlegende (figcaption-Tag)']])
  143. ->add('bildLegende', TextType::class,
  144. [
  145. 'required' => false,
  146. 'constraints' => [
  147. new Length(['max' => 250]),
  148. ],
  149. 'label' => 'Bildlegende',
  150. 'attr' => [
  151. 'maxlength' => 250,
  152. 'placeholder' => 'Beschreibung für Bild 1',
  153. ],
  154. ]
  155. )
  156. ->add('bildLegende2', TextType::class,
  157. [
  158. 'required' => false,
  159. 'constraints' => [
  160. new Length(['max' => 250]),
  161. ],
  162. 'label' => 'Bildlegende',
  163. 'attr' => [
  164. 'maxlength' => 250,
  165. 'placeholder' => 'Beschreibung für Bild 2',
  166. ],
  167. ]
  168. )
  169. ->add('datenschutz', CheckboxType::class,
  170. [
  171. 'mapped' => false,
  172. 'required' => true,
  173. 'label' => 'Ich habe die <a href="'.$this->router->generate('fe.page_datenschutz').'" target="_blank">Datenschutzrichtlinien</a> gelesen und bin damit einverstanden.',
  174. 'label_html' => true,
  175. 'constraints' => [
  176. new NotBlank(),
  177. ],
  178. ]
  179. )
  180. ;
  181. }
  182. #[\Override]
  183. public function configureOptions(OptionsResolver $resolver): void
  184. {
  185. $resolver->setDefaults([
  186. 'data_class' => Vereinsbeitrag::class,
  187. 'attr' => [
  188. 'novalidate' => 'novalidate',
  189. 'autocomplete' => 'off'
  190. ],
  191. ]);
  192. }
  193. }