Bonjour,

J'ai un problème avec un champ qui doit se remplir en fonction d'un autre :

http://www.noelshack.com/2016-10-1457361630-1.png

Quand je clique sur "Créer un Lead" j'ai un formulaire qui apparait :

http://www.noelshack.com/2016-10-145...9-capture2.png

Dans ce formulaire, mon code .js fonctionne, en fonction du département inscrit, j'ai le champ "Ville" qui se remplit (dans l'image ci-dessus, on a bien "PARIS 1er ARRONDISSEMENT").

Ensuite, quand je clique sur "Créer une préqualification" un autre formulaire apparait mais sur la même page (la page ne se recharge pas) :

http://www.noelshack.com/2016-10-1457361826-2.png

C'est un formulaire quasi-identique que le précédent sauf que dans celui-ci, le problème est que, quand je rentre un nouveau code postal, le champ ville ne se modifie pas, il garde ce qui a été tapé dans le formulaire précédent :

http://www.noelshack.com/2016-10-145...2-capture3.png

Voici la vue du premier formulaire :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
<div class="form-errors">{{ form_errors(form) }}</div>
 
 
 
 
{% if lead.appointment is not null %}
    <div id="leadInfos" class="data">
        <div class="header cf">
            <h3>{{ 'Rendez-vous'|trans }}</h3>
            {% include 'CarvivoCrmBundle:Common:_showHide.html.twig' %}
        </div>
        <div class="content">
            <strong>{{ 'Date RDV'|trans }} :</strong> {{ lead.appointment.startTime|date('d / m / Y') }}<br />
            <strong>{{ 'Heure'|trans }} :</strong> {{ lead.appointment.startTime|date('H:i') }}<br />
            <strong>{{ 'Lieu RDV'|trans }} :</strong> {{ lead.appointment.realPlace }}
        </div>
 
    </div>
{% endif %}
 
<div id="leadInfos" class="data">
 
    <div class="header icon-plus">
        <h3>
            {% if lead.id is null %}
                {{ 'Création de lead'|trans }}
            {% else %}
                {{ 'Modification de lead'|trans }}
            {% endif %}
        </h3>
        {% include 'CarvivoCrmBundle:Common:_showHide.html.twig' %}
    </div>
 
    <div class="content cf">
 
        <div class="cf selects">
            {% if (lead.origin is null or lead.origin.code == 'autre' or lead.manualType is not null) or (prelead is defined and prelead is not null) %}
                <div class="custom-select custom-select-infolead" style="width: 250px;">
                    {{ form_widget(form.origin) }}
                </div>
                {{ form_errors(form.origin) }}
            {% else %}
                <div class="custom-select custom-select-infolead" style="display: none;">
                    {{ form_widget(form.origin) }}
                </div>
            {% endif %}
 
            {% if manual is defined and manual == 1 %}
                <div id="manualType" class="field">
                    <div class="custom-select">{{ form_widget(form.manualType) }}</div>
                    {{ form_errors(form.manualType) }}
                </div>
            {% else %}
                {% do form.manualType.setRendered %}
            {% endif %}
 
            <div class="recall">
                {{ form_label(form.recall) }}
                {{ form_widget(form.recall) }}
                {{ form_errors(form.recall) }}
            </div>
 
        </div>
 
 
        {{ form_errors( form.interest ) }}
        <div id="universOccasionEtAutre">
            <div id="universOccasion" class="univers" {% if lead.interest is not null and lead.interest.id != 31 %}style="display: none"{% endif %}>
                <h4>
                    <span class="custom-radio interest-id">
                        {{ form_widget( form.interest[31], {'attr' : {'class' : 'radio-univers'}} ) }}
                        <label for="{{ formName|default('lead') }}_interest_31">{{ 'Univers<br />occasion'|trans|raw }}</label>
                    </span>
                </h4>
                <div class="fields">
                    <div id="adsList1" class="collection-list cf">
                        <div class="ads cf" data-prototype="{% filter escape %}{% include 'CarvivoCrmBundle:Ad:_ad.html.twig' with {'ad': form.VOLead.ads.vars.prototype, 'pvo': 'pvo'} %}{% endfilter %}">
                            {% for ad in form.VOLead.ads %}
                                <div class="collection-item ad cf">{% include 'CarvivoCrmBundle:Ad:_ad.html.twig' with {'ad': ad, 'pvo': 'pvo'} %}</div>
                            {% endfor %}
                            <div style="display:none">{{ form_row(form.VOLead.ads) }}</div>
                        </div>
                    </div>
 
                    <div class="field take-back checkbox">
                        {{ form_widget(form.VOLead.takeBack) }}
                        {{ form_label(form.VOLead.takeBack) }}
                        {{ form_errors(form.VOLead.takeBack) }}
                    </div>
                    <div class="field financing checkbox">
                        {{ form_widget(form.VOLead.financing) }}
                        {{ form_label(form.VOLead.financing) }}
                        {{ form_errors(form.VOLead.financing) }}
                    </div>
                    <div class="field pro-sale checkbox">
                        {{ form_widget(form.VOLead.proSale) }}
                        {{ form_label(form.VOLead.proSale) }}
                        {{ form_errors(form.VOLead.proSale) }}
                    </div>
                    <div class="field trial checkbox">
                        {{ form_widget(form.VOLead.trial) }}
                        {{ form_label(form.VOLead.trial) }}
                        {{ form_errors(form.VOLead.trial) }}
                    </div>
 
                </div>
            </div>
 
            <div id="universAutre" class="univers" {% if lead.interest is not null and lead.interest.id != 35 %}style="display: none"{% endif %}>
                    <h4><span class="custom-radio interest-id">{{ form_widget( form.interest[35], {'attr' : {'class' : 'radio-univers'}} ) }}<label for="{{ formName|default('lead') }}_interest_35">{{ 'Univers<br />autre'|trans|raw }}</label></span></h4>
            </div>
        </div>
 
        <!--div id="universAtelierEtAutre" -->
            <div id="universAtelier" class="univers" {% if lead.interest is not null and lead.interest.id != 40 %}style="display: none"{% endif %}>
                <h4><span class="custom-radio interest-id">{{ form_widget( form.interest[40], {'attr' : {'class' : 'radio-univers'}} ) }}<label for="{{ formName|default('lead') }}_interest_40">{{ 'Univers<br />atelier'|trans|raw }}</label></span></h4>
                <div class="fields">
 
                    <div class="field">
                        <div class="custom-select">{{ form_widget(form.AtelierLead.atelierType) }}</div>
                        {{ form_errors(form.AtelierLead.atelierType) }}
                    </div>
                    <div id="adsList2" class="collection-list cf workshop">
                        <div class="ads cf" data-prototype="{% filter escape %}{% include 'CarvivoCrmBundle:Ad:_ad.html.twig' with {'ad': form.AtelierLead.ads.vars.prototype} %}{% endfilter %}">
                            {% for ad in form.AtelierLead.ads %}
                                <div class="collection-item ad cf">{% include 'CarvivoCrmBundle:Ad:_ad.html.twig' with {'ad': ad} %}</div>
                            {% endfor %}
                            <div style="display:none">{{ form_row(form.AtelierLead.ads) }}</div>
                        </div>
                    </div>
                </div>
                <div class="fields">
 
                    <div class="field">
                        <div class="custom-select">{{ form_widget(form.AtelierLead.appointmentType) }}</div>
                        {{ form_errors(form.AtelierLead.appointmentType) }}
                    </div>
 
                    <div class="field checkbox">
                        {{ form_widget(form.AtelierLead.urgent) }}
                        {{ form_label(form.AtelierLead.urgent) }}
                        {{ form_errors(form.AtelierLead.urgent) }}
                    </div>
 
                    <div id="datesList" class="collection-list cf">
                        <div class="dates cf" data-prototype="{% filter escape %}{% include 'CarvivoCrmBundle:Operator/Lead:_appointmentDate.html.twig' with {'appointmentDate': form.AtelierLead.appointmentDates.vars.prototype} %}{% endfilter %}">
                            {% for appointmentDate in form.AtelierLead.appointmentDates %}
                                <div class="collection-item appointment-date cf">{% include 'CarvivoCrmBundle:Operator/Lead:_appointmentDate.html.twig' with {'appointmentDate': appointmentDate} %}</div>
                            {% endfor %}
                            <div style="display:none">{{ form_row(form.AtelierLead.appointmentDates) }}</div>
                        </div>
                    </div>
 
                </div>
            </div>
        <!-- /div -->
 
        <div id="universNeufEtRechange">
 
            <div id="universNeuf" class="univers" {% if lead.interest is not null and lead.interest.id != 32 %}style="display: none"{% endif %}>
                <h4><span class="custom-radio interest-id">{{ form_widget( form.interest[32], {'attr' : {'class' : 'radio-univers'}} ) }}<label for="{{ formName|default('lead') }}_interest_32">{{ 'Univers<br />neuf'|trans|raw }}</label></span></h4>
                <div class="fields">
                    <div id="adsList3" class="collection-list cf">
                        <div class="ads cf" data-prototype="{% filter escape %}{% include 'CarvivoCrmBundle:Ad:_ad.html.twig' with {'ad': form.VNLead.ads.vars.prototype, 'placeholder': 'Budget'} %}{% endfilter %}">
                            {% for ad in form.VNLead.ads %}
                                <div class="collection-item ad cf">{% include 'CarvivoCrmBundle:Ad:_ad.html.twig' with {'ad': ad, 'placeholder' : 'Budget'} %}</div>
                            {% endfor %}
                            <div style="display:none">{{ form_row(form.VNLead.ads) }}</div>
                        </div>
                    </div>
                    <div class="field take-back checkbox">
                        {{ form_widget(form.VNLead.takeBack) }}
                        {{ form_label(form.VNLead.takeBack) }}
                        {{ form_errors(form.VNLead.takeBack) }}
                    </div>
                    <div class="field financing checkbox">
                        {{ form_widget(form.VNLead.financing) }}
                        {{ form_label(form.VNLead.financing) }}
                        {{ form_errors(form.VNLead.financing) }}
                    </div>
                    <div class="field trial checkbox">
                        {{ form_widget(form.VNLead.trial) }}
                        {{ form_label(form.VNLead.trial) }}
                        {{ form_errors(form.VNLead.trial) }}
                    </div>
                </div>
            </div>
 
            <div id="universRechange" class="univers" {% if lead.interest is not null and lead.interest.id != 34 %}style="display: none"{% endif %}>
                <h4><span class="custom-radio interest-id">{{ form_widget( form.interest[34], {'attr' : {'class' : 'radio-univers'}} ) }}<label for="{{ formName|default('lead') }}_interest_34">{{ 'Univers<br />rechange'|trans|raw }}</label></span></h4>
                <div class="fields">
                    <div id="adsList4" class="collection-list cf just-one">
                        <div class="ads cf" data-prototype="{% filter escape %}{% include 'CarvivoCrmBundle:Ad:_ad.html.twig' with {'ad': form.RechangeLead.ads.vars.prototype} %}{% endfilter %}">
                            {% for ad in form.RechangeLead.ads %}
                                <div class="collection-item ad cf">{% include 'CarvivoCrmBundle:Ad:_ad.html.twig' with {'ad': ad} %}</div>
                            {% endfor %}
                            <div style="display:none">{{ form_row(form.RechangeLead.ads) }}</div>
                        </div>
                    </div>
                    <div class="field">
                        {{ form_widget(form.RechangeLead.sparePart) }}
                        {{ form_errors(form.RechangeLead.sparePart) }}
                    </div>
 
                    <div class="field checkbox">
                        {{ form_widget(form.RechangeLead.urgent) }}
                        {{ form_label(form.RechangeLead.urgent) }}
                        {{ form_errors(form.RechangeLead.urgent) }}
                    </div>
 
                </div>
            </div>
 
            {% do form.interest.setRendered %}
 
        </div>
 
    </div>
</div>
 
<div id="customerInfos" class="data">
 
    <div class="header icon-point">
        <h3>{{ 'Informations prospect'|trans }}</h3>
        {% include 'CarvivoCrmBundle:Common:_showHide.html.twig' %}
    </div>
 
    <div class="content cf">
 
        <div class="left">
            <div class="fields">
                <div class="field check-pro">
                    <div class="icon-play">{{ form_label(form.customer.pro) }}</div>
                    <div class="custom-radio cf">{{ form_widget(form.customer.pro) }}</div>
                    {{ form_errors(form.customer.pro) }}
                </div>
            </div>
 
            <div class="fields">
                <div class="field">
                    <div class="custom-select">{{ form_widget(form.customer.title) }}</div>
                    {{ form_errors(form.customer.title) }}
                </div>
                <div class="field">
                    {{ form_widget(form.customer.firstName) }}
                    {{ form_errors(form.customer.firstName) }}
                </div>
                <div class="field">
                    {{ form_widget(form.customer.lastName) }}
                    {{ form_errors(form.customer.lastName) }}
                </div>
            </div>
 
 
        </div>
 
        <div class="right">
 
            <div class="fields">
                <div class="field favorite-communication">
                    <div class="icon-play">{{ form_label(form.customer.favoriteCommunicationMeans) }}</div>
                    <div class="custom-radio cf">{{ form_widget(form.customer.favoriteCommunicationMeans) }}</div>
                    {{ form_errors(form.customer.favoriteCommunicationMeans) }}
                </div>
            </div>
            <div class="fields">
                <div class="field">
                    <div class="input icon-phone">{{ form_widget(form.customer.phoneNumber) }}</div>
                    {{ form_errors(form.customer.phoneNumber) }}
                    {% if lead.id is not null and lead.customer.phoneNumber is not null%}
                        <div class="call-link">
                            Appeler : {% include 'CarvivoCrmBundle:Operator:_callLink.html.twig' with {'phoneNumber': lead.customer.phoneNumber, 'lead': lead.id} %}
                        </div>
                    {% endif %}
                </div>
                <div class="field">
                    <div class="input icon-arobase">{{ form_widget(form.customer.email) }}</div>
                    {{ form_errors(form.customer.email) }}
                </div>
                <div class="field">
                    <div class="input icon-phone">{{ form_widget(form.customer.otherPhoneNumber) }}</div>
                    {{ form_errors(form.customer.otherPhoneNumber) }}
                </div>
            </div>
            <div class="fields">
                <div class="field">
                    {{ form_widget(form.customer.address.zipcode) }}
                    {{ form_errors(form.customer.address.zipcode) }}
                </div>
            </div>
            <div class="fields">
                <div class="field">
                    {{ form_label(form.transfered) }}
                    {{ form_widget(form.transfered) }}
                    {{ form_errors(form.transfered) }}
                </div>
            </div>
 
            <div class="is-pro cf fields">
                <div class="field">
                    {{ form_widget(form.customer.legalName) }}
                    {{ form_errors(form.customer.legalName) }}
                </div>
                <div class="field">
                    {{ form_widget(form.customer.tradeName) }}
                    {{ form_errors(form.customer.tradeName) }}
                </div>
                <div class="field">
                    {{ form_widget(form.customer.siret) }}
                    {{ form_errors(form.customer.siret) }}
                </div>
                <div class="field">
                    {{ form_widget(form.customer.otherProIdentifier) }}
                    {{ form_errors(form.customer.otherProIdentifier) }}
                </div>
            </div>
        </div>
             <div class="bottom-infos">   
                            <div class="fields">
                <div class="title icon-play">Opt in</div>
                <div class="field cf ios-radio">
                    {{ form_label(form.customer.posOptIn) }}
                    <div class="controls iradio">{{ form_widget(form.customer.posOptIn) }}</div>
                    {{ form_errors(form.customer.posOptIn) }}
                </div>
                <div class="cf"></div>
            </div>
    </div>
 
 
        {% if lead.reminder is not null or lead.appointment is not null  %}
            <div class="fields dates">
                {% if lead.reminder is not null %}
                    <div class="field">
                        <label>{{ 'Date de relance' }}</label>
                        <strong>{{ lead.reminder.reminderDate|date('d/m/Y') }}</strong>
                    </div>
                {% endif %}
                {% if lead.appointment is not null %}
                    <div class="field">
                        <label>{{ 'Date de prise de RDV' }}</label>
                        <strong>{{ lead.appointment.startTime|date('d/m/Y') }}</strong>
                    </div>
                {% endif %}
            </div>
        {% endif %}
 
        {% if lead.id is not null %}
            <a href="{{ path('operator_lead_alert_operators', {'id' : lead.id}) }}" id="alertOperators" class="button icon-bell ajax-box">{{ 'Alerter les opérateurs'|trans }}</a>
        {% endif %}
 
    </div>
 
</div>
 
<div id="customerAddress" class="data">
 
    <div class="header icon-map">
        <h3>{{ 'Adresse'|trans }}</h3>
        {% include 'CarvivoCrmBundle:Common:_showHide.html.twig' %}
    </div>
 
    <div class="content cf">
        <div class="fields">
            <div class="field">
                <div class="icon-play">{{ form_label(form.customer.address.type) }}</div>
                <div class="custom-radio cf">{{ form_widget(form.customer.address.type) }}</div>
                {{ form_errors(form.customer.address.type) }}
            </div>
        </div>
        <div class="fields">
            <div class="field">
                {{ form_widget(form.customer.address.name) }}
                {{ form_errors(form.customer.address.name) }}
            </div>
            <div class="field">
                {{ form_widget(form.customer.address.firstLine) }}
                {{ form_errors(form.customer.address.firstLine) }}
            </div>
            <div class="field">
                {{ form_widget(form.customer.address.secondLine) }}
                {{ form_errors(form.customer.address.secondLine) }}
            </div>
            <div class="field">
                {{ form_widget(form.customer.address.thirdLine) }}
                {{ form_errors(form.customer.address.thirdLine) }}
            </div>
            {% do form.customer.address.mapLink.setRendered %}
            <div class="field">
                <div class="custom-select">{{ form_widget(form.customer.address.city) }}</div>
                {{ form_errors(form.customer.address.city) }}
            </div>
            <div class="field">
                <div class="custom-select">{{ form_widget(form.customer.address.country) }}</div>
                {{ form_errors(form.customer.address.country) }}
            </div>
            <div class="field checkbox no-label">
                {{ form_widget(form.customer.address.notKnown) }}
                {{ form_label(form.customer.address.notKnown) }}
                {{ form_errors(form.customer.address.notKnown) }}
            </div>
        </div>
    </div>
 
</div>
 
{{ render(controller('CarvivoCrmBundle:Operator:sellersList', {'id' : pos, 'absent' : (absent is defined) ? absent : null })) }}
 
<div id="notesMedia" class="data">
 
    <div class="header icon-bubbles">
        <h3>{{ 'Notes et médias'|trans }}</h3>
        {% include 'CarvivoCrmBundle:Common:_showHide.html.twig' %}
    </div>
 
    <div class="content cf">
        <div class="ariane">
            <div class="icon-play">Fil d'Ariane</div>
            {% include 'CarvivoCrmBundle:Note:list.html.twig' %}
            {% if disabled is not defined or disabled == 0 %}
                <div class="fields">
                    <div class="field">
                        {{ form_widget(form.note.content) }}
                        {{ form_errors(form.note.content) }}
                    </div>
                </div>
            {% else %}
                {% do form.note.content.setRendered %}
            {% endif %}
        </div>
        <div class="player-suivi">
            <div class="icon-play">Player conversations</div>
            <div class="fields">
                <div class="field" id="doNotRecord">
                    <div class="checkbox">{{ form_widget(form.doNotRecord) }}</div>
                    <span class="button icon-cancel-circle" id="doNotRecordButton">Ne pas enregistrer</span>
                </div>
                {% include 'CarvivoCrmBundle:Common:_players.html.twig' %}
            </div>
            {% if pos.odl %}
                <a class="button icon-search" id="searchOdl" data-api_url="{% if apiUrl is defined %}{{ apiUrl }}{% endif %}" target="_blank">Rechercher base ODL</a>
            {% endif %}
        </div>
    </div>
</div>
 
<div class="bottom-bar">
 
    <div id="choosePos">
        <div class="custom-select">{{ form_widget(form.ownerGroup, { 'attr': {'data-url': path('operator_lead_fill_sellers')}}) }}</div>
        {{ form_errors(form.ownerGroup) }}
    </div>
    <div id="chooseSeller">
        <div class="custom-select">{{ form_widget(form.seller, {'empty_value' : 'Affecter à un utilisateur'}) }}</div>
        {{ form_errors(form.seller) }}
    </div>
 
    <div class="buttons universOccasion">
 
        {% if pos.takeAppointment %}
            {% if lead.appointment is null %}
                {{ form_widget(form.VOLead.save_and_appointment) }}
            {% else %}
                {{ form_widget(form.VOLead.save_and_appointment, {label: 'Mettre à jour le rendez-vous'}) }}
            {% endif %}
        {% else %}
            {% do form.VOLead.save_and_appointment.setRendered %}
        {% endif %}
 
        {% if lead.customer.id is null %}
            {{ form_widget(form.VOLead.save_and_create) }}
        {% else %}
            {{ form_widget(form.VOLead.save_and_create, {label: 'Valider le lead'}) }}
        {% endif %}
 
        {{ form_widget(form.VOLead.save_and_close) }}
    </div>
 
    <div class="buttons universAtelier">
 
        {% if pos.takeAppointmentAtelier and pos.hasAtelierProcess  %}
            {% if lead.appointment is null %}
                {{ form_widget(form.AtelierLead.save_and_appointment) }}
            {% else %}
                {{ form_widget(form.AtelierLead.save_and_appointment, {label: 'Mettre à jour le rendez-vous'}) }}
            {% endif %}
        {% else %}
            {% do form.AtelierLead.save_and_appointment.setRendered %}
        {% endif %}
 
        {% if lead.customer.id is null %}
            {{ form_widget(form.AtelierLead.save_and_create) }}
        {% else %}
            {{ form_widget(form.AtelierLead.save_and_create, {label: 'Valider le lead'}) }}
        {% endif %}
 
        {{ form_widget(form.AtelierLead.save_and_close) }}
    </div>
 
    <div class="buttons universAutre">
 
 
        {% do form.AutreLead.save_and_appointment.setRendered %}
 
        {% if lead.customer.id is null %}
            {{ form_widget(form.AutreLead.save_and_create) }}
        {% else %}
            {{ form_widget(form.AutreLead.save_and_create, {label: 'Valider le lead'}) }}
        {% endif %}
 
        {{ form_widget(form.AutreLead.save_and_close) }}
    </div>
 
    <div class="buttons universNeuf">
 
        {% if pos.takeAppointmentVN and pos.hasVnProcess %}
            {% if lead.appointment is null %}
                {{ form_widget(form.VNLead.save_and_appointment) }}
            {% else %}
                {{ form_widget(form.VNLead.save_and_appointment, {label: 'Mettre à jour le rendez-vous'}) }}
            {% endif %}
        {% else %}
            {% do form.VNLead.save_and_appointment.setRendered %}
        {% endif %}
 
        {% if lead.customer.id is null %}
            {{ form_widget(form.VNLead.save_and_create) }}
        {% else %}
            {{ form_widget(form.VNLead.save_and_create, {label: 'Valider le lead'}) }}
        {% endif %}
 
        {{ form_widget(form.VNLead.save_and_close) }}
    </div>
 
    <div class="buttons universRechange">
 
        {% if pos.takeAppointmentRechange and pos.hasRechangeProcess %}
            {% if lead.appointment is null %}
                {{ form_widget(form.RechangeLead.save_and_appointment) }}
            {% else %}
                {{ form_widget(form.RechangeLead.save_and_appointment, {label: 'Mettre à jour le rendez-vous'}) }}
            {% endif %}
        {% else %}
            {% do form.RechangeLead.save_and_appointment.setRendered %}
        {% endif %}
 
        {% if lead.customer.id is null %}
            {{ form_widget(form.RechangeLead.save_and_create) }}
        {% else %}
            {{ form_widget(form.RechangeLead.save_and_create, {label: 'Valider le lead'}) }}
        {% endif %}
 
        {{ form_widget(form.RechangeLead.save_and_close) }}
    </div>
    {% if (lead.id is not null and operatorReminders is defined and operatorReminders|length < 1) %}
        <a href="{{ path('reminder_operator', { 'id': lead.id , 'type' : 'operator' }) }}" id="recontactOperator" class="ajax-box icon-clock">{{ 'Rappel'|trans }}</a>
    {% endif %}
</div>
Voici la vue du deuxième formulaire :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<div class="form-errors">{{ form_errors(form) }}</div>
 
 
<div id="customerInfos" class="data">
 
    <div class="header icon-point">
        <h3>{{ 'Informations prospect'|trans }}</h3>
        {% include 'CarvivoCrmBundle:Common:_showHide.html.twig' %}
    </div>
 
    <div class="content cf">
 
        <div class="left">
            <div class="fields">
                <div class="field check-pro">
                    <div class="icon-play">{{ form_label(form.customer.pro) }}</div>
                    <div class="custom-radio cf">{{ form_widget(form.customer.pro) }}</div>
                    {{ form_errors(form.customer.pro) }}
                </div>
            </div>
 
            <div class="fields">
                <div class="field">
                    <div class="custom-select">{{ form_widget(form.customer.title) }}</div>
                    {{ form_errors(form.customer.title) }}
                </div>
                <div class="field">
                    {{ form_widget(form.customer.firstName) }}
                    {{ form_errors(form.customer.firstName) }}
                </div>
                <div class="field">
                    {{ form_widget(form.customer.lastName) }}
                    {{ form_errors(form.customer.lastName) }}
                </div>
            </div>
 
 
        </div>
 
        <div class="right">
 
            <div class="fields">
                <div class="field favorite-communication">
                    <div class="icon-play">{{ form_label(form.customer.favoriteCommunicationMeans) }}</div>
                    <div class="custom-radio cf">{{ form_widget(form.customer.favoriteCommunicationMeans) }}</div>
                    {{ form_errors(form.customer.favoriteCommunicationMeans) }}
                </div>
            </div>
            <div class="fields">
                <div class="field">
                    <div class="input icon-phone">{{ form_widget(form.customer.phoneNumber) }}</div>
                </div>
                <div class="field">
                    <div class="input icon-arobase">{{ form_widget(form.customer.email) }}</div>
                    {{ form_errors(form.customer.email) }}
                </div>
                <div class="field">
                    <div class="input icon-phone">{{ form_widget(form.customer.otherPhoneNumber) }}</div>
                    {{ form_errors(form.customer.otherPhoneNumber) }}
                </div>
            </div>
            <div class="fields">
                <div class="field">
                    {{ form_widget(form.customer.address.zipcode) }}
                    {{ form_errors(form.customer.address.zipcode) }}
                </div>
            </div>
 
            <div class="is-pro cf fields">
                <div class="field">
                    {{ form_widget(form.customer.legalName) }}
                    {{ form_errors(form.customer.legalName) }}
                </div>
                <div class="field">
                    {{ form_widget(form.customer.tradeName) }}
                    {{ form_errors(form.customer.tradeName) }}
                </div>
                <div class="field">
                    {{ form_widget(form.customer.siret) }}
                    {{ form_errors(form.customer.siret) }}
                </div>
                <div class="field">
                    {{ form_widget(form.customer.otherProIdentifier) }}
                    {{ form_errors(form.customer.otherProIdentifier) }}
                </div>
            </div>
        </div>
        <div class="bottom-infos">   
            <div class="fields">
                <div class="title icon-play">Opt in</div>
                <div class="field cf ios-radio">
                    {{ form_label(form.customer.posOptIn) }}
                    <div class="controls iradio">{{ form_widget(form.customer.posOptIn) }}</div>
                    {{ form_errors(form.customer.posOptIn) }}
                </div>
                <div class="cf"></div>
            </div>
        </div>
 
        <div class="bottom-infos">   
            <div class="fields">
                <div class="title icon-play">Traceur indiqué au prospect</div>
                <div class="field">
                    <div class="custom-select"> {{ form_widget(form.carvivoPhone) }} </div>
                    {{ form_errors(form.carvivoPhone) }}
                </div>
                <div class="cf"></div>
            </div>
        </div>
        <div class="bottom-infos">   
            <div class="fields">
                <div class="title icon-play">Marque</div>
                <div class="field">
                    <div class="custom-select"> {{ form_widget(form.brand) }} </div>
                    {{ form_errors(form.brand) }}
                </div>
                <div class="cf"></div>
            </div>
        </div>
 
    </div>
</div>
 
<div id="customerAddress" class="data">
 
    <div class="header icon-map">
        <h3>{{ 'Adresse'|trans }}</h3>
        {% include 'CarvivoCrmBundle:Common:_showHide.html.twig' %}
    </div>
 
    <div class="content cf">
        <div class="fields">
            <div class="field">
                <div class="icon-play">{{ form_label(form.customer.address.type) }}</div>
                <div class="custom-radio cf">{{ form_widget(form.customer.address.type) }}</div>
                {{ form_errors(form.customer.address.type) }}
            </div>
        </div>
        <div class="fields">
            <div class="field">
                {{ form_widget(form.customer.address.name) }}
                {{ form_errors(form.customer.address.name) }}
            </div>
            <div class="field">
                {{ form_widget(form.customer.address.firstLine) }}
                {{ form_errors(form.customer.address.firstLine) }}
            </div>
            <div class="field">
                {{ form_widget(form.customer.address.secondLine) }}
                {{ form_errors(form.customer.address.secondLine) }}
            </div>
            <div class="field">
                {{ form_widget(form.customer.address.thirdLine) }}
                {{ form_errors(form.customer.address.thirdLine) }}
            </div>
            {% do form.customer.address.mapLink.setRendered %}
            <div class="field">
                <div class="custom-select">{{ form_widget(form.customer.address.city) }}</div>
                {{ form_errors(form.customer.address.city) }}
            </div>
            <div class="field">
                <div class="custom-select">{{ form_widget(form.customer.address.country) }}</div>
                {{ form_errors(form.customer.address.country) }}
            </div>
            <div class="field checkbox no-label">
                {{ form_widget(form.customer.address.notKnown) }}
                {{ form_label(form.customer.address.notKnown) }}
                {{ form_errors(form.customer.address.notKnown) }}
            </div>
        </div>
    </div>
 
</div>
Et voici le code js qui permet de remplir le champ "Ville" automatiquement en fonction du code postal :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
var otherCity = function() {
    var city = $( "[id$=_address_city]" );
    if(city.find('option#otherCity:checked').length > 0) {
        var newCity = '<input type="text" name="' + city.attr('name') + '" id="' + city.attr('id') + '"/>';
        city.parents('.custom-select').find('.customSelect').remove();
        city.replaceWith(newCity);
        $('[id$=_address_city]').focus();
    } else {
        $('#otherInput').hide();
    }
}
 
var getCities = function() {
    var zipcode = $('[id$=_address_zipcode]');
    var city = $('[id$=_address_city]');
    if(typeof zipcode.val() != 'undefined' ) {
        if(zipcode.val().length == 5) {
            $.ajax({
                type: "GET",
                url: Routing.generate('cities_list', {'zipcode': zipcode.val()}),
                success: function(response){
                    if(response.data.htmlContent != '') {
                        var newCity = '<select name="' + city.attr('name') + '" id="' + city.attr('id') + '">' + response.data.htmlContent + '</select>';
                        city.parents('.custom-select').find('.customSelect').remove();
                        city.replaceWith(newCity);
                        $('.custom-select select:not(".hasCustomSelect")').customSelect();
                        $('[id$=_address_city]').bind('change', otherCity);
                    }
                }
            });
        }
    }
};
$(function() {
    $('[id$=_address_zipcode]').bind('keyup', getCities);
});
Dans le deuxième formulaire, j'ai essayé d'attribué un nom à la classe qui contient le champ du code postal :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
            <div class="fields">
                <div class="field prelead_zip_code">
                    {{ form_widget(form.customer.address.zipcode) }}
                    {{ form_errors(form.customer.address.zipcode) }}
                </div>
            </div>
Mais je n'arrive pas à l'indiqué au fichier js, il prend en compte seulement le champ du premier formulaire.

Merci pour votre aide.