Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- New :
- <div class="form-group">
- {{ form_label(form.residenceAttributes, null, {'label': 'Attributs de la résidence', 'label_attr': {'class': 'col-md-2 control-label'}}) }}
- <div class="col-md-6">
- <table class="table table-bordered no-margin">
- <thead>
- <tr>
- <th>Icone</th>
- <th>Texte</th>
- <th width="135">Action</th>
- </tr>
- </thead>
- <tbody id="attributs-add-list"
- data-prototype="{% filter escape %}{{ include('@App/Backend/Residence/_prototypes/attribut.html.twig', { 'attribut': form.residenceAttributes.vars.prototype }) }}{% endfilter %}">
- {{ form_widget(form.residenceAttributes) }}
- </tbody>
- <tbody>
- <tr>
- <td colspan="3" class="text-right">
- <button id="add-attribut" class="btn btn-block btn-success"><i class="fa fa-plus"></i> Ajouter un attribut</button>
- </td>
- </tr>
- </tbody>
- </table>
- </div>
- </div>
- Edit :
- <div class="form-group">
- {{ form_label(edit_form.residenceAttributes, null, {'label': 'Attributs de la résidence', 'label_attr': {'class': 'col-md-2 control-label'}}) }}
- <div class="col-md-6">
- <table class="table table-bordered no-margin">
- <thead>
- <tr>
- <th>Icone</th>
- <th>Texte</th>
- <th width="135">Action</th>
- </tr>
- </thead>
- <tbody id="attributs-add-list"
- data-prototype="{% filter escape %}{{ include('@App/Backend/Residence/_prototypes/attribut.html.twig', { 'attribut': edit_form.residenceAttributes.vars.prototype }) }}{% endfilter %}">
- {% for attribut in edit_form.residenceAttributes %}
- <tr class="delete-parent">
- <td>{{ form_widget(attribut.icon) }}</td>
- <td>{{ form_widget(attribut.text, {'attr': {'class': 'form-control', 'placeholder' : 'Texte'}}) }}</td>
- <td>
- <button class="btn btn-danger btn-block delete-row">
- <i class="fa fa-times"></i> Supprimer
- </button>
- </td>
- </tr>
- {% endfor %}
- {{ form_widget(edit_form.residenceAttributes) }}
- </tbody>
- <tbody>
- <tr>
- <td colspan="3" class="text-right">
- <button id="add-attribut" class="btn btn-block btn-success"><i class="fa fa-plus"></i> Ajouter un attribut</button>
- </td>
- </tr>
- </tbody>
- </table>
- </div>
- </div>
- JS :
- var attributsAddList = $('#attributs-add-list');
- $('#add-attribut').click(function () {
- attributsAddList.append(attributsAddList.data('prototype').replace(/__name__/g, attributsAddList.children('').length));
- $("[id$='_icon']").select2({
- theme: "bootstrap",
- placeholder: 'Choisir une icone',
- minimumResultsForSearch: Infinity,
- width: '100%'
- });
- return false;
- });
- $(document).on('click', '.delete-row', function () {
- $(this).parentsUntil('.delete-parent').parent().remove();
- });
- prototype :
- <tr class="delete-parent">
- <td>{{ form_widget(attribut.icon) }}</td>
- <td>{{ form_widget(attribut.text, {'attr': {'class': 'form-control', 'placeholder' : 'Texte'}}) }}</td>
- <td>
- <button class="btn btn-danger btn-block delete-row">
- <i class="fa fa-times"></i> Supprimer
- </button>
- </td>
- </tr>
Advertisement
Add Comment
Please, Sign In to add comment