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.                 'html5' => true,
  91.                 'constraints' => [
  92.                     new Assert\Range([
  93.                         'min' => 0,
  94.                         'max' => 9999999999999.99,
  95.                     ]),
  96.                 ],
  97.             ])
  98.             //Fremde Sachen
  99.             ->add('foreignDeductible'NumberType::class, [
  100.                 'scale' => 2,
  101.                 'label' => "Selbstbehalt",
  102.                 'required' => false,
  103.                 'html5' => true,
  104.                 'constraints' => [
  105.                     new Assert\Range([
  106.                         'min' => 0,
  107.                         'max' => 9999999999999.99,
  108.                     ]),
  109.                 ],
  110.             ])
  111.             ->add('foreignDamageCosts'NumberType::class, [
  112.                 'scale' => 2,
  113.                 'label' => "Schadensumme",
  114.                 'required' => false,
  115.                 'html5' => true,
  116.                 'constraints' => [
  117.                     new Assert\Range([
  118.                         'min' => 0,
  119.                         'max' => 9999999999999.99,
  120.                     ]),
  121.                 ],
  122.             ])
  123.             //Beteiligte Person
  124.             ->add('involvedPerson'InvolvedPersonType::class, [
  125.                 'label' => "Beteiligte Person",
  126.             ])
  127.             ->add('driver'NameAddressBlockType::class, [
  128.                 'label' => "Angaben zum Fahrer",
  129.                 'required' => true,
  130.                 'constraints' => [
  131.                     new Assert\NotBlank(),
  132.                 ],
  133.             ])
  134.             ->add('driverBirthdate'null, [
  135.                 'label' => "Geburtsdatum des Fahrers",
  136.                 'required' => true,
  137.                 'constraints' => [
  138.                     new Assert\NotBlank(),
  139.                 ],
  140.                 'years' => range(date('Y'), date('Y')-100),
  141.             ])
  142.             ->add('mfLicense'MfLicenseType::class, [
  143.                 'label' => 'Führerausweis',
  144.                 'required' => true,
  145.             ])
  146.             ->add('policeReport'null, [
  147.                 'label' => "Von welcher polizeistelle wurde ein Rapport aufgenommen?",
  148.                 'required' => false,
  149.             ])
  150.             ->add('persons'CollectionType::class, [
  151.                 'label' => false,
  152.                 'entry_type' => PersonType::class,
  153.                 'entry_options' => [],
  154.                 'allow_add' => true,
  155.                 'allow_delete' => true,
  156.                 'by_reference' => false,
  157.                 'prototype' => true,
  158.                 'prototype_name' => '__item__',
  159.             ])
  160.             ->add('remark'null, [
  161.                 'label' => "Beschädigte Sachen / Weitere Angaben / Bemerkungen",
  162.                 'required' => false,
  163.             ])
  164.             ->add('name'null, [
  165.                 'label' => false,
  166.                 'required' => true,
  167.                 'constraints' => [
  168.                     new Assert\NotBlank(),
  169.                 ],
  170.                 'attr' => [
  171.                     'placeholder' => 'Name',
  172.                 ],
  173.             ])
  174.             ->add('email'EmailType::class, [
  175.                 'label' => false,
  176.                 'required' => true,
  177.                 'constraints' => [
  178.                     new Assert\NotBlank(),
  179.                     new Assert\Email(),
  180.                 ],
  181.                 'attr' => [
  182.                     'placeholder' => 'Email',
  183.                 ],
  184.             ])
  185.             ->add('ccEmail'EmailType::class, [
  186.                 'label' => false,
  187.                 'required' => false,
  188.                 'constraints' => [
  189.                     new Assert\Email(),
  190.                 ],
  191.                 'attr' => [
  192.                     'placeholder' => 'CC Email',
  193.                 ],
  194.             ])
  195.             ->add('claimFiles'FileType::class,[
  196.                 'label' => 'Dateien',
  197.                 'data_class' => null,
  198.                 'required' => false,
  199.                 'multiple' => true,
  200.                 'mapped' => false,
  201.                 'constraints' => [
  202.                     new Assert\All([
  203.                         new File(['maxSize' => '100m'])
  204.                     ])
  205.                 ]
  206.             ])
  207.             ->add('submit'SubmitType::class, [
  208.                 'label' => 'Senden',
  209.                 'attr' => [
  210.                     'class' => 'btn btn-primary',
  211.                 ],
  212.             ])
  213.         ;
  214.     }
  215.     public function configureOptions(OptionsResolver $resolver): void
  216.     {
  217.         $resolver->setDefaults([
  218.             'data_class' => Claim::class,
  219.         ]);
  220.     }
  221. }