Skip to content

Commit

Permalink
Update bootstrap_3_layout.html.twig
Browse files Browse the repository at this point in the history
If you use a collection with choices and allow_delete flag, it was ignored (e.g. fos user roles).
  • Loading branch information
user121216 committed Dec 12, 2016
1 parent 66770db commit 5e32b6a
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions Resources/views/form/bootstrap_3_layout.html.twig
Expand Up @@ -135,6 +135,29 @@
{% block choice_widget_collapsed -%}
{% set attr = attr|merge({class: (attr.class|default('') ~ ' form-control')|trim}) %}
{{- parent() -}}
{% if form.parent.vars.allow_delete|default(false) %}
{% set remove_item_javascript %}
$(function() {
if (event.preventDefault) event.preventDefault(); else event.returnValue = false;

var containerDiv = $('#{{ id }}').parents('.form-group:first');
var parentDiv = containerDiv.parents('[data-prototype]:first');
containerDiv.remove();
parentDiv.trigger('easyadmin.collection.item-deleted');

if (0 == parentDiv.children().length && 'undefined' !== parentDiv.attr('data-empty-collection')) {
$(parentDiv.attr('data-empty-collection')).insertBefore(parentDiv);
}
});
{% endset %}

<div class="text-right field-collection-item-action">
<a href="#" onclick="{{ remove_item_javascript|raw }}" class="text-danger">
<i class="fa fa-remove"></i>
{{ 'action.remove_item'|trans({}, 'EasyAdminBundle') }}
</a>
</div>
{% endif %}
{%- endblock %}

{% block choice_widget_expanded -%}
Expand Down

0 comments on commit 5e32b6a

Please sign in to comment.