-
Notifications
You must be signed in to change notification settings - Fork 6
/
_participants.html.twig
82 lines (72 loc) · 3.13 KB
/
_participants.html.twig
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
{% import 'macros/layout.html.twig' as layout %}
{% set content %}
{% if isOrganizer %}
{{ form_errors(form) }}
{# Valid participants should be shown below invalid ones. #}
{% set validParticipants = [] %}
{{ form_start(form, {'method': 'post', 'attr': {'class': 'form-horizontal save-participants-form', 'autocomplete': 'off'}}) }}
{% for participant in form.participants %}
{% set invalidParticipant = false %}
{% if not(participant.vars.valid) %}
{% set invalidParticipant = true %}
{% endif %}
{% set participantRow %}
<div class="form-group participant-row{% if invalidParticipant %} has-error{% endif %}">
<div class="col-sm-4">
{{ form_widget(participant, {'attr': {'class': 'user-input'}}) }}
{% if invalidParticipant %}
<span class="font-awesome invalid-input"></span>
{% else %}
<span class="font-awesome valid-input"></span>
{% endif %}
</div>
<div class="col-sm-2">
<button type="button" class="btn btn-default remove-participant">
{{ msg('remove') }}
</button>
</div>
</div>
{% endset %}
{##
# If invalid, show immediately, otherwise merge into valid ones that
# will show below the invalid ones.
#}
{% if invalidParticipant %}
{{ participantRow }}
{% else %}
{% set validParticipants = validParticipants|merge([participantRow]) %}
{% endif %}
{% endfor %}
{# Render valid participants. #}
{% for row in validParticipants %}
{{ row }}
{% endfor %}
<div class="col-sm-6 col-sm-offset-6 save-participants-btn">
{{ form_widget(form.submit, {'label': msg('save-participants'), 'attr': {'class': 'btn-primary'}}) }}
</div>
<div class="form-group col-sm-6 event-add-participants">
<label for="form_new_participants">{{ msg('add-more-participants') }}</label>
{{ form_widget(form.new_participants, {'attr': {'class': 'event-new-participants', 'rows': 10}}) }}
</div>
{% if form.participants|length == 0 %}
<div class="col-sm-6">
{{ form_widget(form.submit, {'label': msg('save-participants'), 'attr': {'class': 'btn-primary'}}) }}
</div>
{% endif %}
{{ form_row(form._token) }}
{{ form_end(form, {'render_rest': false}) }}
{% else %}
{% for participant in event.participants %}
<div class="participant-row">
{{ participant.username }}
</div>
{% endfor %}
{% endif %}
{% endset %}
{{
layout.eventAccordion(
'participants',
event.numParticipants ~ ' ' ~ msg('num-participants', [event.numParticipants]),
content
)
}}