Factor multientry form
This commit is contained in:
parent
8501f07956
commit
dcb34ad451
3 changed files with 33 additions and 93 deletions
|
@ -9,7 +9,6 @@
|
|||
<title>
|
||||
{% block title_onglet %}{% trans "Annuaire des élèves de l'ENS" %}{% endblock %}
|
||||
</title>
|
||||
<link rel="stylesheet" type="text/css" href="view_fiche_files/style.css">
|
||||
<link rel="stylesheet" type="text/css" href="{% static "fiches/css/normalize.css" %}" />
|
||||
<link rel="stylesheet" type="text/css" href="{% static "fiches/css/annuaire.css" %}" />
|
||||
</head>
|
||||
|
|
|
@ -68,120 +68,36 @@
|
|||
data-type-placeholder="{% trans "Personnel" %}"
|
||||
data-value-placeholder="{% trans "0612345678" %}"
|
||||
>
|
||||
{{ phone_form.non_field_errors }}
|
||||
{{ phone_form.management_form }}
|
||||
<label for="id_phone">{% trans "Numéro(s) de téléphone :" %}</label>
|
||||
{% for form in phone_form %}
|
||||
<div class="form-sub-entry">
|
||||
{{ form.name }}
|
||||
{{ form.number }}
|
||||
{{ form.DELETE }}
|
||||
{% for hidden in form.hidden_fields %}
|
||||
{{ hidden }}
|
||||
{% endfor %}
|
||||
<button type=button" class="remove-button"></button>
|
||||
</div>
|
||||
{% endfor %}
|
||||
<div class="form-sub-entry-template">
|
||||
{{ phone_form.empty_form.name }}
|
||||
{{ phone_form.empty_form.number }}
|
||||
{{ phone_form.empty_form.DELETE }}
|
||||
{% for hidden in phone_form.empty_form.hidden_fields %}
|
||||
{{ hidden }}
|
||||
{% endfor %}
|
||||
<button type="button" class="remove-button"></button>
|
||||
</div>
|
||||
<button type="button" class="add-sub-entry-button">{% trans "Ajouter un numéro" %}</button>
|
||||
{% trans "Ajouter un numéro" as add_number %}
|
||||
{% include "fiches/multientry.html" with formset=phone_form new_entry_text=add_number %}
|
||||
</div>
|
||||
<div
|
||||
class="form-entry multi-entry"
|
||||
data-type-placeholder="{% trans "InstaTok" %}"
|
||||
data-value-placeholder="{% trans "mon_profil_instatok" %}"
|
||||
>
|
||||
{{ social_form.non_field_errors }}
|
||||
{{ social_form.management_form }}
|
||||
<label for="id_social">{% trans "Réseaux sociaux :" %}</label>
|
||||
{% for form in social_form %}
|
||||
<div class="form-sub-entry">
|
||||
{{ form.name }}
|
||||
{{ form.content }}
|
||||
{{ form.DELETE }}
|
||||
{% for hidden in form.hidden_fields %}
|
||||
{{ hidden }}
|
||||
{% endfor %}
|
||||
<button type=button" class="remove-button"></button>
|
||||
</div>
|
||||
{% endfor %}
|
||||
<div class="form-sub-entry-template">
|
||||
{{ social_form.empty_form.name }}
|
||||
{{ social_form.empty_form.content }}
|
||||
{{ social_form.empty_form.DELETE }}
|
||||
{% for hidden in social_form.empty_form.hidden_fields %}
|
||||
{{ hidden }}
|
||||
{% endfor %}
|
||||
<button type="button" class="remove-button"></button>
|
||||
</div>
|
||||
<button type="button" class="add-sub-entry-button">{% trans "Ajouter un réseau social" %}</button>
|
||||
{% trans "Ajouter un réseau social" as add_social %}
|
||||
{% include "fiches/multientry.html" with formset=social_form new_entry_text=add_social %}
|
||||
</div>
|
||||
<div
|
||||
class="form-entry multi-entry"
|
||||
data-type-placeholder="{% trans "Professionelle" %}"
|
||||
data-value-placeholder="{% trans "moi@ens.fr" %}"
|
||||
>
|
||||
{{ mail_form.non_field_errors }}
|
||||
{{ mail_form.management_form }}
|
||||
<label for="id_mail">{% trans "Mail(s):" %}</label>
|
||||
{% for form in mail_form %}
|
||||
<div class="form-sub-entry">
|
||||
{{ form.name }}
|
||||
{{ form.mail }}
|
||||
{{ form.DELETE }}
|
||||
{% for hidden in form.hidden_fields %}
|
||||
{{ hidden }}
|
||||
{% endfor %}
|
||||
<button type=button" class="remove-button"></button>
|
||||
</div>
|
||||
{% endfor %}
|
||||
<div class="form-sub-entry-template">
|
||||
{{ mail_form.empty_form.name }}
|
||||
{{ mail_form.empty_form.mail }}
|
||||
{{ mail_form.empty_form.DELETE }}
|
||||
{% for hidden in mail_form.empty_form.hidden_fields %}
|
||||
{{ hidden }}
|
||||
{% endfor %}
|
||||
<button type="button" class="remove-button"></button>
|
||||
</div>
|
||||
<button type="button" class="add-sub-entry-button">{% trans "Ajouter un email" %}</button>
|
||||
{% trans "Ajouter un email" as add_mail %}
|
||||
{% include "fiches/multientry.html" with formset=mail_form new_entry_text=add_mail %}
|
||||
</div>
|
||||
<div
|
||||
class="form-entry multi-entry"
|
||||
data-type-placeholder="{% trans "Bureau" %}"
|
||||
data-value-placeholder="{% trans "45 rue d'Ulm" %}"
|
||||
>
|
||||
{{ address_form.non_field_errors }}
|
||||
{{ address_form.management_form }}
|
||||
<label for="id_address">{% trans "Adresse(s):" %}</label>
|
||||
{% for form in address_form %}
|
||||
<div class="form-sub-entry">
|
||||
{{ form.name }}
|
||||
{{ form.content }}
|
||||
{{ form.DELETE }}
|
||||
{% for hidden in form.hidden_fields %}
|
||||
{{ hidden }}
|
||||
{% endfor %}
|
||||
<button type=button" class="remove-button"></button>
|
||||
</div>
|
||||
{% endfor %}
|
||||
<div class="form-sub-entry-template">
|
||||
{{ address_form.empty_form.name }}
|
||||
{{ address_form.empty_form.content }}
|
||||
{{ address_form.empty_form.DELETE }}
|
||||
{% for hidden in address_form.empty_form.hidden_fields %}
|
||||
{{ hidden }}
|
||||
{% endfor %}
|
||||
<button type="button" class="remove-button"></button>
|
||||
</div>
|
||||
<button type="button" class="add-sub-entry-button">{% trans "Ajouter une adresse" %}</button>
|
||||
{% trans "Ajouter une adresse" as add_address %}
|
||||
{% include "fiches/multientry.html" with formset=address_form new_entry_text=add_address %}
|
||||
</div>
|
||||
<div class="form-entry">
|
||||
<label for="id_text_field">{% trans "Champ libre :" %}</label>
|
||||
|
|
25
fiches/templates/fiches/multientry.html
Normal file
25
fiches/templates/fiches/multientry.html
Normal file
|
@ -0,0 +1,25 @@
|
|||
{{ formset.non_field_errors }}
|
||||
{{ formset.management_form }}
|
||||
{% for form in formset %}
|
||||
{{ form.non_field_errors }}
|
||||
<div class="form-sub-entry">
|
||||
{% for field in form.visible_fields %}
|
||||
{{field.errors}}
|
||||
{{field}}
|
||||
{% endfor %}
|
||||
{% for field in form.hidden_fields %}
|
||||
{{field}}
|
||||
{% endfor %}
|
||||
<button type=button" class="remove-button"></button>
|
||||
</div>
|
||||
{% endfor %}
|
||||
<div class="form-sub-entry-template">
|
||||
{% for field in form.visible_fields %}
|
||||
{{field}}
|
||||
{% endfor %}
|
||||
{% for field in form.hidden_fields %}
|
||||
{{field}}
|
||||
{% endfor %}
|
||||
<button type="button" class="remove-button"></button>
|
||||
</div>
|
||||
<button type="button" class="add-sub-entry-button">{{ new_entry_text }}</button>
|
Loading…
Add table
Add a link
Reference in a new issue