2021-05-17 19:34:49 +00:00
{% macro render_inline_fields(field, template, render, check=None) %}
< div class = "inline-field" id = "{{ field.id }}" >
{# existing inline form fields #}
< div class = "inline-field-list" >
{% for subfield in field %}
2022-03-02 22:35:20 +00:00
< div id = "{{ subfield.id }}" class = "inline-field card card-body bg-light" >
2021-05-17 19:34:49 +00:00
{%- if not check or check(subfield) %}
< legend >
< small >
{{ field.label.text }} #{{ loop.index }}
< div class = "pull-right" >
{% if subfield.get_pk and subfield.get_pk() %}
< input type = "checkbox" name = "del-{{ subfield.id }}" id = "del-{{ subfield.id }}" / >
< label for = "del-{{ subfield.id }}" style = "display: inline" > {{ _gettext('Delete?') }}< / label >
{% else %}
< a href = "javascript:void(0)" value = "{{ _gettext('Are you sure you want to delete this record?') }}" class = "inline-remove-field" > < i class = "fa fa-times glyphicon glyphicon-remove" > < / i > < / a >
{% endif %}
< / div >
< / small >
< / legend >
< div class = 'clearfix' > < / div >
{%- endif -%}
{{ render(subfield) }}
< / div >
{% endfor %}
< / div >
{# template for new inline form fields #}
< div class = "inline-field-template hide" >
{% filter forceescape %}
2022-03-02 22:35:20 +00:00
< div class = "inline-field card card-body bg-light" >
2021-05-17 19:34:49 +00:00
< legend >
< small > {{ _gettext('New') }} {{ field.label.text }}< / small >
< div class = "pull-right" >
< a href = "javascript:void(0)" value = "{{ _gettext('Are you sure you want to delete this record?') }}" class = "inline-remove-field" > < span class = "fa fa-times glyphicon glyphicon-remove" > < / span > < / a >
< / div >
< / legend >
< div class = 'clearfix' > < / div >
{{ render(template) }}
< / div >
{% endfilter %}
< / div >
2022-03-02 22:35:20 +00:00
< a id = "{{ field.id }}-button" href = "javascript:void(0)" class = "btn btn-primary" role = "button" onclick = "faForm.addInlineField(this, '{{ field.id }}');" > {{ _gettext('Add') }} {{ field.label.text }}< / a >
2021-05-17 19:34:49 +00:00
< / div >
{% endmacro %}