{% load i18n admin_urls admin_static admin_modify djadmin_form djadmin_inline_form %}
<div class="row">
    <div class="formset-field col s12" data-formset-prefix="{{ element.inline.formset.prefix }}">
        {% part element.inline label %}
            <ul class="collection with-header">
                <li class="collection-header {{ request.ADMIN_COLOR_THEME }} white-text">
                    <h5>Inline {{ element.inline.opts.verbose_name_plural|capfirst }}</h5>
                </li>
            </ul>{% endpart %}
        <div data-formset-body>
            {% for inline_admin_form in element.inline %}
            {% if inline_admin_form.form.prefix ==  element.inline.formset.empty_form.prefix %}<script type="form-template" data-formset-empty-form>{% endif %}
            
            <div class="col s12 m6 l4"  data-formset-form>
                <div class="card">
                    <div class="card-content">
                        {% part inline_admin_form.form hidden %}
                        {% if inline_admin_form.needs_explicit_pk_field %}{{ inline_admin_form.pk_field.field }}{% endif %}
                        {{ inline_admin_form.fk_field.field }}
                        {% for fieldset in inline_admin_form %}{% for line in fieldset %}{% for field in line %}
                            {% if field.field.is_hidden %} {{ field.field }} {% endif %}
                        {% endfor %}{% endfor %}{% endfor %}
                        {% endpart %}

                        {% part inline_admin_form.form visible %}
                        {% for fieldset in inline_admin_form %}{% for line in fieldset %}{% for field in line %}{% if not field.field.is_hidden %}
                        <div class="row">
                            {% if field.is_readonly %}
                                <div class="row">
                                    <div class="input-field col s12">
                                        {% if '<img' in field.contents %}
                                            <input type="checkbox" id="test7" {% if 'icon-yes' in field.contents %}checked="checked"{% endif %} disabled="disabled" />
                                            <label for="test7">{{ field.field.label|title }}</label>
                                        {% else %}
                                            <label class="active">{{ field.field.label|title }}</label>
                                            <input disabled value="{{ field.contents }}">
                                        {% endif %}
                                    </div>
                                </div>
                             {% else %}
                                    {% with form=inline_admin_form.form %}{% render field.field %}{% endrender %}{% endwith %}
                             {% endif %}
                        </div>
                        {% endif %}{% endfor %}{% endfor %}{% endfor %}
                        {% endpart %}
                    </div>
                    {% if element.inline.formset.can_delete %}
                    <div class="card-action">
                        <div class="right-align">
                            <div style="display:none">{{ inline_admin_form.deletion_field.field }}</div>
                            <button type="button" class="btn waves-effect waves-light {{ request.ADMIN_COLOR_THEME }}" data-formset-delete-button>Delete</button>
                        </div>
                    </div>
                    {% endif %}
                </div>
            </div>
            {% if inline_admin_form.form.prefix ==  element.inline.formset.empty_form.prefix %}</script>{% endif %}
            {% endfor %}
        </div>
    <div class="input-field col l12">
        <button type="button" class="btn waves-effect waves-light {{ request.ADMIN_COLOR_THEME }}" style="width:100%" data-formset-add>Add New {{ element.inline.opts.verbose_name}}</button>
        </div>
        {{ element.inline.formset.management_form }}
    </div>
</div>
