forked from ninsuo/symfony-collection
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jquery.collection.html.twig
33 lines (32 loc) · 1.35 KB
/
jquery.collection.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
{#
# jquery.collection.html.twig
#
# Adds the following html attributes to the root node of your collection fields:
#
# - data-prototype-name: placeholder used in the prototype to replace element indexes on the collection
# - data-allow-add: if set to false, plugin will automatically set allow_add option to false
# - data-allow-delete: if set to false, plugin will automatically set allow_remove option to false
# - data-name-prefix: contains the collection's prefix used in descendant field names
#
# Those information let you configure the plugin options automatically.
#
# If you are already using a form theme, you can use both by using:
# {%
# form_theme myForm
# 'FuzAppBundle::my-form-theme.html.twig'
# 'FuzAppBundle::jquery.collection.html.twig'
# ...
# %}
#}
{% block collection_widget %}
{% spaceless %}
{% if prototype is defined %}
{% set attr = attr|merge({'data-prototype': form_row(prototype)}) %}
{% set attr = attr|merge({'data-prototype-name': prototype.vars.name}) %}
{% endif %}
{% set attr = attr|merge({'data-allow-add': allow_add ? 1 : 0}) %}
{% set attr = attr|merge({'data-allow-remove': allow_delete ? 1 : 0 }) %}
{% set attr = attr|merge({'data-name-prefix': full_name}) %}
{{ block('form_widget') }}
{% endspaceless %}
{% endblock collection_widget %}