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.             ])
  53.             ->add('claimAddress'AddressBlockType::class, [
  54.                 'label' => "Unfallstelle",
  55.                 'required' => true,
  56.                 'constraints' => [
  57.                     new Assert\NotBlank(),
  58.                 ],
  59.             ])
  60.             ->add('claimDescription'null, [
  61.                 'label' => "Genaue Beschreibung des Unfallhergangs (auch dann, wenn ein Polizeirapport aufgenommen wurde)",
  62.                 'required' => true,
  63.                 'constraints' => [
  64.                     new Assert\NotBlank(),
  65.                 ],
  66.             ])
  67.             ->add('responsible'ChoiceType::class, [
  68.                 'label' => 'Eigenverschulden',
  69.                 'choices' => [
  70.                     'Unklar' => 0,
  71.                     'Nein' => 1,
  72.                     'Ja' => 2,
  73.                 ],
  74.                 'required' => true,
  75.                 'placeholder' => false
  76.             ])
  77.             //Angaben zum Schaden
  78.             ->add('claimDamageCause'null, [
  79.                 'label' => "Schadenursache",
  80.                 'required' => false,
  81.             ])
  82.             ->add('claimDamage'null, [
  83.                 'label' => "Schadenart",
  84.                 'required' => false,
  85.             ])
  86.             ->add('damageCosts'NumberType::class, [
  87.                 'scale' => 2,
  88.                 'label' => "Schadensumme",
  89.                 'required' => false,
  90.                 'constraints' => [
  91.                     new Assert\Range([
  92.                         'min' => 0,
  93.                         'max' => 9999999999999.99,
  94.                     ]),
  95.                 ],
  96.             ])
  97.             //Fremde Sachen
  98.             ->add('foreignDeductible'NumberType::class, [
  99.                 'scale' => 2,
  100.                 'label' => "Selbstbehalt",
  101.                 'required' => false,
  102.                 'constraints' => [
  103.                     new Assert\Range([
  104.                         'min' => 0,
  105.                         'max' => 9999999999999.99,
  106.                     ]),
  107.                 ],
  108.             ])
  109.             ->add('foreignDamageCosts'NumberType::class, [
  110.                 'scale' => 2,
  111.                 'label' => "Schadensumme",
  112.                 'required' => false,
  113.                 'constraints' => [
  114.                     new Assert\Range([
  115.                         'min' => 0,
  116.                         'max' => 9999999999999.99,
  117.                     ]),
  118.                 ],
  119.             ])
  120.             //Beteiligte Person
  121.             ->add('involvedPerson'InvolvedPersonType::class, [
  122.                 'label' => "Beteiligte Person",
  123.             ])
  124.             ->add('driver'NameAddressBlockType::class, [
  125.                 'label' => "Angaben zum Fahrer",
  126.                 'required' => true,
  127.                 'constraints' => [
  128.                     new Assert\NotBlank(),
  129.                 ],
  130.             ])
  131.             ->add('driverBirthdate'null, [
  132.                 'label' => "Geburtsdatum des Fahrers",
  133.                 'required' => true,
  134.                 'constraints' => [
  135.                     new Assert\NotBlank(),
  136.                 ],
  137.                 'years' => range(date('Y'), date('Y')-100),
  138.             ])
  139.             ->add('mfLicense'MfLicenseType::class, [
  140.                 'label' => 'Führerausweis',
  141.                 'required' => true,
  142.             ])
  143.             ->add('policeReport'null, [
  144.                 'label' => "Von welcher polizeistelle wurde ein Rapport aufgenommen?",
  145.                 'required' => false,
  146.             ])
  147.             ->add('persons'CollectionType::class, [
  148.                 'label' => false,
  149.                 'entry_type' => PersonType::class,
  150.                 'entry_options' => [],
  151.                 'allow_add' => true,
  152.                 'allow_delete' => true,
  153.                 'by_reference' => false,
  154.                 'prototype' => true,
  155.                 'prototype_name' => '__item__',
  156.             ])
  157.             ->add('remark'null, [
  158.                 'label' => "Beschädigte Sachen / Weitere Angaben / Bemerkungen",
  159.                 'required' => false,
  160.             ])
  161.             ->add('name'null, [
  162.                 'label' => false,
  163.                 'required' => true,
  164.                 'constraints' => [
  165.                     new Assert\NotBlank(),
  166.                 ],
  167.                 'attr' => [
  168.                     'placeholder' => 'Name',
  169.                 ],
  170.             ])
  171.             ->add('email'EmailType::class, [
  172.                 'label' => false,
  173.                 'required' => true,
  174.                 'constraints' => [
  175.                     new Assert\NotBlank(),
  176.                     new Assert\Email(),
  177.                 ],
  178.                 'attr' => [
  179.                     'placeholder' => 'Email',
  180.                 ],
  181.             ])
  182.             ->add('ccEmail'EmailType::class, [
  183.                 'label' => false,
  184.                 'required' => false,
  185.                 'constraints' => [
  186.                     new Assert\Email(),
  187.                 ],
  188.                 'attr' => [
  189.                     'placeholder' => 'CC Email',
  190.                 ],
  191.             ])
  192.             ->add('claimFiles'FileType::class,[
  193.                 'label' => 'Dateien',
  194.                 'data_class' => null,
  195.                 'required' => false,
  196.                 'multiple' => true,
  197.                 'mapped' => false,
  198.                 'constraints' => [
  199.                     new Assert\All([
  200.                         new File(['maxSize' => '100m'])
  201.                     ])
  202.                 ]
  203.             ])
  204.             ->add('submit'SubmitType::class, [
  205.                 'label' => 'Senden',
  206.                 'attr' => [
  207.                     'class' => 'btn btn-primary',
  208.                 ],
  209.             ])
  210.         ;
  211.     }
  212.     public function configureOptions(OptionsResolver $resolver): void
  213.     {
  214.         $resolver->setDefaults([
  215.             'data_class' => Claim::class,
  216.         ]);
  217.     }
  218. }