src/Form/ClaimMFType.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use App\Entity\Claim;
  4. use Symfony\Component\Form\AbstractType;
  5. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  6. use Symfony\Component\Form\Extension\Core\Type\CollectionType;
  7. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  8. use Symfony\Component\Form\Extension\Core\Type\NumberType;
  9. use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  10. use Symfony\Component\Form\FormBuilderInterface;
  11. use Symfony\Component\OptionsResolver\OptionsResolver;
  12. use Symfony\Component\Validator\Constraints as Assert;
  13. use Symfony\Component\Form\Extension\Core\Type\FileType;
  14. use Symfony\Component\Validator\Constraints\File;
  15. class ClaimMFType extends AbstractType
  16. {
  17.     public function buildForm(FormBuilderInterface $builder, array $options): void
  18.     {
  19.         $builder
  20.             ->add('department'null, [
  21.                 'label' => 'Dienststelle',
  22.                 'required' => true,
  23.                 'constraints' => [
  24.                     new Assert\NotBlank(),
  25.                 ],
  26.             ])
  27.             ->add('mfType'null, [
  28.                 'label' => 'Fahrzeug Art',
  29.                 'required' => true,
  30.                 'constraints' => [
  31.                     new Assert\NotBlank(),
  32.                 ],
  33.             ])
  34.             ->add('mfModel'null, [
  35.                 'label' => 'Fahrzeug Typ',
  36.                 'required' => true,
  37.                 'constraints' => [
  38.                     new Assert\NotBlank(),
  39.                 ],
  40.             ])
  41.             ->add('mfPlate'null, [
  42.                 'label' => 'Kontrollschild',
  43.                 'required' => true,
  44.                 'constraints' => [
  45.                     new Assert\NotBlank(),
  46.                 ],
  47.             ])
  48.             ->add('claimDate'null, [
  49.                 'label' => 'Wann hat sich das Schadenereignis zugetragen?',
  50.                 'required' => false,
  51.                 'years' => range(date('Y'), date('Y')-5),
  52.                 'constraints' => [
  53.                     new Assert\NotBlank(),
  54.                 ],
  55.                 'label_attr' => [
  56.                     'required' => 'required',
  57.                     'class' => 'required',
  58.                 ],
  59.             ])
  60.             ->add('claimAddress'AddressBlockType::class, [
  61.                 'label' => "Unfallstelle",
  62.                 'required' => true,
  63.                 'constraints' => [
  64.                     new Assert\NotBlank(),
  65.                 ],
  66.             ])
  67.             ->add('claimDescription'null, [
  68.                 'label' => "Genaue Beschreibung des Unfallhergangs (auch dann, wenn ein Polizeirapport aufgenommen wurde)",
  69.                 'required' => true,
  70.                 'constraints' => [
  71.                     new Assert\NotBlank(),
  72.                 ],
  73.             ])
  74.             ->add('responsible'ChoiceType::class, [
  75.                 'label' => 'Eigenverschulden',
  76.                 'choices' => [
  77.                     'Unklar' => 0,
  78.                     'Nein' => 1,
  79.                     'Ja' => 2,
  80.                 ],
  81.                 'required' => true,
  82.                 'placeholder' => false
  83.             ])
  84.             //Angaben zum Schaden
  85.             ->add('claimDamageCause'null, [
  86.                 'label' => "Schadenursache",
  87.                 'required' => false,
  88.             ])
  89.             ->add('claimDamage'null, [
  90.                 'label' => "Schadenart",
  91.                 'required' => false,
  92.             ])
  93.             ->add('damageCosts'NumberType::class, [
  94.                 'scale' => 2,
  95.                 'label' => "Schadensumme",
  96.                 'required' => false,
  97.                 'html5' => true,
  98.                 'constraints' => [
  99.                     new Assert\Range([
  100.                         'min' => 0,
  101.                         'max' => 9999999999999.99,
  102.                     ]),
  103.                 ],
  104.             ])
  105.             //Fremde Sachen
  106.             ->add('foreignDeductible'NumberType::class, [
  107.                 'scale' => 2,
  108.                 'label' => "Selbstbehalt",
  109.                 'required' => false,
  110.                 'html5' => true,
  111.                 'constraints' => [
  112.                     new Assert\Range([
  113.                         'min' => 0,
  114.                         'max' => 9999999999999.99,
  115.                     ]),
  116.                 ],
  117.             ])
  118.             ->add('foreignDamageCosts'NumberType::class, [
  119.                 'scale' => 2,
  120.                 'label' => "Schadensumme",
  121.                 'required' => false,
  122.                 'html5' => true,
  123.                 'constraints' => [
  124.                     new Assert\Range([
  125.                         'min' => 0,
  126.                         'max' => 9999999999999.99,
  127.                     ]),
  128.                 ],
  129.             ])
  130.             //Beteiligte Person
  131.             ->add('involvedPerson'InvolvedPersonType::class, [
  132.                 'label' => "Beteiligte Person",
  133.             ])
  134.             ->add('driver'NameAddressBlockType::class, [
  135.                 'label' => "Angaben zum Fahrer",
  136.                 'required' => true,
  137.                 'constraints' => [
  138.                     new Assert\NotBlank(),
  139.                 ],
  140.             ])
  141.             ->add('driverBirthdate'null, [
  142.                 'label' => "Geburtsdatum des Fahrers",
  143.                 'required' => true,
  144.                 'constraints' => [
  145.                     new Assert\NotBlank(),
  146.                 ],
  147.                 'years' => range(date('Y'), date('Y')-100),
  148.             ])
  149.             ->add('mfLicense'MfLicenseType::class, [
  150.                 'label' => 'Führerausweis',
  151.                 'required' => true,
  152.             ])
  153.             ->add('policeReport'null, [
  154.                 'label' => "Von welcher polizeistelle wurde ein Rapport aufgenommen?",
  155.                 'required' => false,
  156.             ])
  157.             ->add('persons'CollectionType::class, [
  158.                 'label' => false,
  159.                 'entry_type' => PersonType::class,
  160.                 'entry_options' => [],
  161.                 'allow_add' => true,
  162.                 'allow_delete' => true,
  163.                 'by_reference' => false,
  164.                 'prototype' => true,
  165.                 'prototype_name' => '__item__',
  166.             ])
  167.             ->add('remark'null, [
  168.                 'label' => "Beschädigte Sachen / Weitere Angaben / Bemerkungen",
  169.                 'required' => false,
  170.             ])
  171.             ->add('name'null, [
  172.                 'label' => false,
  173.                 'required' => true,
  174.                 'constraints' => [
  175.                     new Assert\NotBlank(),
  176.                 ],
  177.                 'attr' => [
  178.                     'placeholder' => 'Name',
  179.                 ],
  180.             ])
  181.             ->add('email'EmailType::class, [
  182.                 'label' => false,
  183.                 'required' => true,
  184.                 'constraints' => [
  185.                     new Assert\NotBlank(),
  186.                     new Assert\Email(),
  187.                 ],
  188.                 'attr' => [
  189.                     'placeholder' => 'Email',
  190.                 ],
  191.             ])
  192.             ->add('ccEmail'EmailType::class, [
  193.                 'label' => false,
  194.                 'required' => false,
  195.                 'constraints' => [
  196.                     new Assert\Email(),
  197.                 ],
  198.                 'attr' => [
  199.                     'placeholder' => 'CC Email',
  200.                 ],
  201.             ])
  202.             ->add('claimFiles'FileType::class,[
  203.                 'label' => 'Dateien',
  204.                 'data_class' => null,
  205.                 'required' => false,
  206.                 'multiple' => true,
  207.                 'mapped' => false,
  208.                 'constraints' => [
  209.                     new Assert\All([
  210.                         new File(['maxSize' => '100m'])
  211.                     ])
  212.                 ]
  213.             ])
  214.             ->add('submit'SubmitType::class, [
  215.                 'label' => 'Senden',
  216.                 'attr' => [
  217.                     'class' => 'btn btn-primary',
  218.                 ],
  219.             ])
  220.         ;
  221.     }
  222.     public function configureOptions(OptionsResolver $resolver): void
  223.     {
  224.         $resolver->setDefaults([
  225.             'data_class' => Claim::class,
  226.         ]);
  227.     }
  228. }