AdresseFieldset.php 6.59 KB
Newer Older
1
2
<?php

Antony Le Courtes's avatar
Antony Le Courtes committed
3
namespace Application\Form\Adresse;
4
5

use Application\Form\AbstractFieldset;
6
use Application\Form\Elements\PaysSelect;
7
use Application\Service\Traits\AdresseNumeroComplServiceAwareTrait;
8
use Application\Service\Traits\ContextServiceAwareTrait;
Antony Le Courtes's avatar
Antony Le Courtes committed
9
use Application\Service\Traits\PaysServiceAwareTrait;
10
use Application\Service\Traits\StatutIntervenantServiceAwareTrait;
Antony Le Courtes's avatar
Antony Le Courtes committed
11
use Application\Service\Traits\VoirieServiceAwareTrait;
12
13

/**
Antony Le Courtes's avatar
Antony Le Courtes committed
14
 * Description of AdresseFieldset
15
16
 *
 */
Antony Le Courtes's avatar
Antony Le Courtes committed
17
class AdresseFieldset extends AbstractFieldset
18
19
20
{
    use ContextServiceAwareTrait;
    use StatutIntervenantServiceAwareTrait;
Antony Le Courtes's avatar
Antony Le Courtes committed
21
22
    use PaysServiceAwareTrait;
    use VoirieServiceAwareTrait;
23
    use AdresseNumeroComplServiceAwareTrait;
24
25
26
27
28
29
30
31
32
33
34

    static private $franceId;



    /**
     * This function is automatically called when creating element with factory. It
     * allows to perform various operations (add elements...)
     */
    public function init()
    {
Antony Le Courtes's avatar
Antony Le Courtes committed
35
        $this->addElements();
36
37
38
39
40
41
42
43
44
45
46
47
    }



    /**
     * @return self
     */
    private function addElements()
    {


        /**
48
         * Précision
49
50
         */
        $this->add([
51
            'name'       => 'precisions',
52
            'options'    => [
53
                'label'         => 'Précisions',
54
55
56
57
58
                'label_options' => [
                    'disable_html_escape' => true,
                ],
            ],
            'attributes' => [
59
60
                'class' => 'dossierElement',
                'rows'  => 2,
61
62
63
64
            ],
            'type'       => 'Textarea',
        ]);

65
66
67
68
        /**
         * Lieu dit
         */
        $this->add([
69
70
            'name'       => 'lieuDit',
            'options'    => [
71
                'label' => 'Lieu dit',
72
            ],
73
74
75
76
            'attributes' => [
                'class' => 'dossierElement',
            ],
            'type'       => 'Text',
77
78
79
80
81
82
83
84
        ]);

        /**
         * Numéro
         */
        $this->add([
            'name'       => 'numero',
            'options'    => [
85
                'label' => 'N°',
86
87
            ],
            'attributes' => [
88
                'class'       => 'dossierElement',
89
                'placeholder' => 'N°',
90
91
92
                'pattern'     => '[0-9]*',
                'title'       => 'Le champs doit contenir uniquement des numéros',
                'maxlength'   => 4,
93
94
95
96
97
98
99
100
            ],
            'type'       => 'Text',
        ]);

        /**
         * complement
         */
        $this->add([
101
102
            'name'       => 'numeroComplement',
            'options'    => [
103
                'label'         => 'Compl.',
104
105
106
107
                'empty_option'  => ' ',
                'value_options' => \UnicaenApp\Util::collectionAsOptions($this->getServiceAdresseNumeroCompl()->getList()),
            ],
            'attributes' => [
108
                'class'            => 'selectpicker dossierElement',
109
                'data-live-search' => 'true',
110
            ],
111
            'type'       => 'Select',
112
113
        ]);

114

115
116
117
118
        /**
         * voirie
         */
        $this->add([
119
120
121
122
123
124
125
            'name'       => 'voirie',
            'options'    => [
                'label'         => 'Voirie',
                'empty_option'  => ' ',
                'value_options' => \UnicaenApp\Util::collectionAsOptions($this->getServiceVoirie()->getList()),
            ],
            'attributes' => [
126
                'class'            => 'selectpicker dossierElement',
127
                'data-live-search' => 'true',
128
                'data-size'        => 10,
129
            ],
130
            'type'       => 'Select',
131
        ]);
Antony Le Courtes's avatar
Antony Le Courtes committed
132

133
134
135
136
137
138
        /**
         * voie
         */
        $this->add([
            'name'       => 'voie',
            'options'    => [
139
                'label' => 'Voie',
140
141
            ],
            'attributes' => [
142
                'class'       => 'dossierElement',
143
                'placeholder' => 'nom de la voie',
144
145
146
147
148
149
150
151
152
            ],
            'type'       => 'Text',
        ]);
        /**
         * Code postal
         */
        $this->add([
            'name'       => 'codePostal',
            'options'    => [
153
154
155
156
                'label'         => 'Code postal <span class="text-danger">*</span>',
                'label_options' => [
                    'disable_html_escape' => true,
                ],],
157
            'attributes' => [
158
                'class'       => 'dossierElement',
159
                'placeholder' => 'Code postal',
160
161
162
163
164
165
166
167
            ],
            'type'       => 'Text',
        ]);

        /**
         * Ville
         */
        $this->add([
Antony Le Courtes's avatar
Antony Le Courtes committed
168
            'name'       => 'ville',
169
            'options'    => [
170
171
172
173
                'label'         => 'Ville <span class="text-danger">*</span>',
                'label_options' => [
                    'disable_html_escape' => true,
                ],],
174
            'attributes' => [
175
                'class'       => 'dossierElement',
176
                'placeholder' => 'Ville',
177
178
179
180
181
182
183
184
185
            ],
            'type'       => 'Text',
        ]);

        /**
         * Pays
         */


Antony Le Courtes's avatar
Antony Le Courtes committed
186
187
188
        $this->add([
            'name'       => 'pays',
            'options'    => [
189
190
191
192
                'label'         => 'Pays <span class="text-danger">*</span>',
                'label_options' => [
                    'disable_html_escape' => true,
                ],],
Antony Le Courtes's avatar
Antony Le Courtes committed
193
            'attributes' => [
194
                'class'            => 'selectpicker dossierElement',
195
                'data-live-search' => 'true',
Antony Le Courtes's avatar
Antony Le Courtes committed
196
197
198
            ],
            'type'       => 'Select',
        ]);
199

Antony Le Courtes's avatar
Antony Le Courtes committed
200
        $this->get('pays')
201
202
            ->setValueOptions(\UnicaenApp\Util::collectionAsOptions($this->getServicePays()->getList()));

203
204
205
206
207
208
209
210
211
212
213
214
215
216
217

        return $this;
    }



    /**
     * Should return an array specification compatible with
     * {@link Zend\InputFilter\Factory::createInputFilter()}.
     *
     * @return array
     */
    public function getInputFilterSpecification()
    {

218
        $spec = [
219
            'precisions'       => [
220
221
                'required' => false,
            ],
222
            'lieuDit'          => [
223
224
                'required' => false,
            ],
225
            'numero'           => [
226
227
                'required' => false,
            ],
228
            'numeroComplement' => [
229
230
                'required' => false,
            ],
231
            'voirie'           => [
232
233
234
235
236
                'required' => false,
            ],
            'voie'             => [
                'required' => false,
            ],
237
            'codePostal'       => [
238
239
                'required' => false,
            ],
240
            'ville'            => [
241
242
243
244
245
246
247
248
249
                'required' => false,
            ],
            'pays'             => [
                'required' => false,
            ],

        ];

        return $spec;
250
251
252
    }

}