PaymentOrderType::configureOptions()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 1
b 0
f 0
1
<?php
2
/*
3
 * Copyright (C) 2020  Jan Böhmer
4
 *
5
 * This program is free software: you can redistribute it and/or modify
6
 * it under the terms of the GNU Affero General Public License as published
7
 * by the Free Software Foundation, either version 3 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU Affero General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU Affero General Public License
16
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
17
 */
18
19
namespace App\Form;
20
21
use App\Entity\PaymentOrder;
22
use Symfony\Component\Form\AbstractType;
23
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
24
use Symfony\Component\Form\Extension\Core\Type\DateType;
25
use Symfony\Component\Form\Extension\Core\Type\EmailType;
26
use Symfony\Component\Form\Extension\Core\Type\MoneyType;
27
use Symfony\Component\Form\Extension\Core\Type\ResetType;
28
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
29
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
30
use Symfony\Component\Form\Extension\Core\Type\TextType;
31
use Symfony\Component\Form\FormBuilderInterface;
32
use Symfony\Component\OptionsResolver\OptionsResolver;
33
use Vich\UploaderBundle\Form\Type\VichFileType;
34
35
class PaymentOrderType extends AbstractType
36
{
37
    public function buildForm(FormBuilderInterface $builder, array $options)
38
    {
39
        $builder->add('first_name', TextType::class, [
40
            'label' => 'payment_order.first_name.label',
41
            'empty_data' => '',
42
            'attr' => [
43
                'placeholder' => 'payment_order.first_name.placeholder',
44
                'autocomplete' => 'given_name',
45
            ],
46
        ]);
47
48
        $builder->add('last_name', TextType::class, [
49
            'label' => 'payment_order.last_name.label',
50
            'empty_data' => '',
51
            'attr' => [
52
                'placeholder' => 'payment_order.last_name.placeholder',
53
                'autocomplete' => 'family_name',
54
            ],
55
        ]);
56
57
        $builder->add('contact_email', EmailType::class, [
58
            'label' => 'payment_order.contact_email.label',
59
            'empty_data' => '',
60
            'attr' => [
61
                'placeholder' => 'payment_order.contact_email.placeholder',
62
                'autocomplete' => 'email',
63
            ],
64
        ]);
65
66
        $builder->add('project_name', TextType::class, [
67
            'label' => 'payment_order.project_name.label',
68
            'help' => 'payment_order.project_name.help',
69
            'empty_data' => '',
70
            'attr' => [
71
                'placeholder' => 'payment_order.project_name.placeholder',
72
            ],
73
        ]);
74
75
        $builder->add('funding_id', TextType::class, [
76
            'label' => 'payment_order.funding_id.label',
77
            'help' => 'payment_order.funding_id.help',
78
            'required' => false,
79
            'empty_data' => '',
80
            'attr' => [
81
                'placeholder' => 'payment_order.funding_id.placeholder',
82
            ],
83
        ]);
84
85
        $builder->add('fsr_kom_resolution', CheckboxType::class, [
86
            'label' => 'payment_order.fsr_kom.label',
87
            'required' => false,
88
        ]);
89
90
        $builder->add('resolution_date', DateType::class, [
91
            'label' => 'payment_order.resolution_date.label',
92
            'required' => false,
93
            'html5' => true,
94
            'widget' => 'single_text',
95
        ]);
96
97
        $builder->add('department', DepartmentChoiceType::class, [
98
            'label' => 'payment_order.department.label',
99
        ]);
100
101
        $builder->add('amount', MoneyType::class, [
102
            'label' => 'payment_order.amount.label',
103
            'divisor' => 100,
104
            'currency' => 'EUR',
105
            'attr' => [
106
                'placeholder' => 'payment_order.amount.placeholder',
107
            ],
108
        ]);
109
110
        $builder->add('bank_info', PayeeInfoType::class, [
111
            'label' => false,
112
        ]);
113
114
        /*
115
        $builder->add('printed_form_file', VichFileType::class, [
116
            'label' => 'payment_order.printed_form.label',
117
            'help' => 'payment_order.printed_form.help',
118
            'help_html' => true,
119
        ]); */
120
121
        $builder->add('references_file', VichFileType::class, [
122
            'label' => 'payment_order.references.label',
123
            'help' => 'payment_order.references.help',
124
        ]);
125
126
        $builder->add('comment', TextareaType::class, [
127
            'label' => 'payment_order.comment.label',
128
            'empty_data' => '',
129
            'required' => false,
130
        ]);
131
132
        $builder->add('submit', SubmitType::class, [
133
            'label' => 'payment_order.submit',
134
            'attr' => [
135
                'class' => 'btn btn-primary',
136
            ],
137
        ]);
138
139
        $builder->add('submit_new', SubmitType::class, [
140
            'label' => 'payment_order.submit_new',
141
            'attr' => [
142
                'class' => 'btn btn-secondary',
143
            ],
144
        ]);
145
146
        $builder->add('reset', ResetType::class, [
147
            'label' => 'payment_order.discard',
148
            'attr' => [
149
                'class' => 'btn btn-danger',
150
            ],
151
        ]);
152
    }
153
154
    public function configureOptions(OptionsResolver $resolver)
155
    {
156
        $resolver->setDefault('data_class', PaymentOrder::class);
157
        $resolver->setDefault('validation_groups', ['Default', 'frontend', 'fsr_blocked']);
158
    }
159
}
160