modalitys
This commit is contained in:
@@ -165,6 +165,102 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% set prototype %}
|
||||
<div class="modality-item border rounded p-3 mt-3 mb-3">
|
||||
|
||||
{# EN #}
|
||||
<div class="input-group mb-3">
|
||||
<span class="input-group-text">EN</span>
|
||||
{{ form_widget(formQuestion.modalitys.vars.prototype.name_en, {
|
||||
attr: {
|
||||
class: 'form-control',
|
||||
placeholder: 'Nom (EN)'
|
||||
}
|
||||
}) }}
|
||||
</div>
|
||||
{{ form_errors(formQuestion.modalitys.vars.prototype.name_en) }}
|
||||
|
||||
{# FR #}
|
||||
<div class="input-group mb-3">
|
||||
<span class="input-group-text">FR</span>
|
||||
{{ form_widget(formQuestion.modalitys.vars.prototype.name_fr, {
|
||||
attr: {
|
||||
class: 'form-control',
|
||||
placeholder: 'Nom (FR)'
|
||||
}
|
||||
}) }}
|
||||
</div>
|
||||
{{ form_errors(formQuestion.modalitys.vars.prototype.name_fr) }}
|
||||
|
||||
{# AR #}
|
||||
<div class="input-group mb-3">
|
||||
<span class="input-group-text">AR</span>
|
||||
{{ form_widget(formQuestion.modalitys.vars.prototype.name_ar, {
|
||||
attr: {
|
||||
class: 'form-control',
|
||||
placeholder: 'الاسم (AR)',
|
||||
dir: 'rtl'
|
||||
}
|
||||
}) }}
|
||||
</div>
|
||||
{{ form_errors(formQuestion.modalitys.vars.prototype.name_ar) }}
|
||||
|
||||
|
||||
</div>
|
||||
{% endset %}
|
||||
|
||||
{# modalities #}
|
||||
<div class="row mt-4">
|
||||
<div class="col-md-8">
|
||||
<div id="modalities" data-prototype="{{ prototype|e('html_attr') }}">
|
||||
|
||||
{% for modality in formQuestion.modalitys %}
|
||||
<div class="modality-item border rounded p-3 mb-3">
|
||||
|
||||
<div class="input-group mb-3">
|
||||
<span class="input-group-text">EN</span>
|
||||
{{ form_widget(modality.name_en, {
|
||||
attr: { class: 'form-control', placeholder: 'Nom (EN)' }
|
||||
}) }}
|
||||
</div>
|
||||
{{ form_errors(modality.name_en) }}
|
||||
|
||||
<div class="input-group mb-3">
|
||||
<span class="input-group-text">FR</span>
|
||||
{{ form_widget(modality.name_fr, {
|
||||
attr: { class: 'form-control', placeholder: 'Nom (FR)' }
|
||||
}) }}
|
||||
</div>
|
||||
{{ form_errors(modality.name_fr) }}
|
||||
|
||||
<div class="input-group mb-3">
|
||||
<span class="input-group-text">AR</span>
|
||||
{{ form_widget(modality.name_ar, {
|
||||
attr: {
|
||||
class: 'form-control',
|
||||
placeholder: 'الاسم (AR)',
|
||||
dir: 'rtl'
|
||||
}
|
||||
}) }}
|
||||
</div>
|
||||
{{ form_errors(modality.name_ar) }}
|
||||
|
||||
<button type="button" class="remove-modality btn btn-danger btn-sm"> Supprimer </button>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<button type="button" id="add-modality" class="btn btn-primary">Ajouter une modalité</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@@ -198,7 +294,6 @@
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
|
||||
console.log("ddddd");
|
||||
var $collection = $('#questions-collection');
|
||||
var $addButton = $('.add-question');
|
||||
|
||||
@@ -252,6 +347,36 @@
|
||||
$(this).find('h5').text('Question N: ' + (index + 1));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
//modalities add-modality
|
||||
const container = document.getElementById('modalities');
|
||||
const addButton = document.getElementById('add-modality');
|
||||
let index = container.children.length;
|
||||
|
||||
addButton.addEventListener('click', () => {
|
||||
const prototype = container.dataset.prototype;
|
||||
const html = prototype.replace(/__name__/g, index);
|
||||
index++;
|
||||
|
||||
const div = document.createElement('div');
|
||||
div.classList.add('modality-item');
|
||||
div.innerHTML = html +
|
||||
'<button type="button" class="remove-modality btn btn-danger">Supprimer</button>';
|
||||
|
||||
container.appendChild(div);
|
||||
});
|
||||
|
||||
|
||||
container.addEventListener('click', (e) => {
|
||||
if (e.target.classList.contains('remove-modality')) {
|
||||
e.target.closest('.modality-item').remove();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user