Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use form_collection field by field ? #149

Open
shoudini opened this issue Jul 9, 2024 · 0 comments
Open

How to use form_collection field by field ? #149

shoudini opened this issue Jul 9, 2024 · 0 comments

Comments

@shoudini
Copy link

shoudini commented Jul 9, 2024

In the template example we prepared below, CRUD operations can be performed well with the {{ form }} tag as a field by field. However, we cannot perform a similar CRUD operation with the {{ form_collection }} tag.

{% formsetify form %}
<django-formset endpoint="{{ request.path }}" csrf-token="{{ csrf_token }}">
    <form id="{{ form.form_id }}"></form>
    {% include "partials/formset/non_field_errors.html" %}
    {% for field in form %}
        {% if field.is_hidden %}
            {{ field }}
        {% else %}
            {% include "partials/formset/bootstrap/field_group.html" %}  
        {% endif %}
    {% endfor %}
    {% if add %}
        <button type="button" class="btn btn-secondary" df-click="disable -> spinner -> submit({add: true}) -> okay(500) -> proceed !~ enable -> bummer(500)">Kaydet
            <span class="dj-button-decorator ms-2">
                {% static 'images/svg/kaydet.svg' %}
            </span>
        </button>
    {% else %}
        <button type="button" class="btn btn-soft-primary py-2" df-click="submit({update: true}) -> proceed">Güncelle</button>
        <button type="button" name="silinsinmi" aria-describedby="id_ebildirge.silinsinmi_helptext" form="id_ebildirge" id="id_ebildirge.silinsinmi" df-click="activate" class="btn btn-danger">Sil</button>
        {% endif %}
        <button type="button" class="btn btn-soft-primary py-2" df-click="reset">Sıfırla</button>
        <a class="btn btn-soft-primary py-2"  href="{% url 'dashboards:listele' %}">Geri</a>
</django-formset>

In other words, when we try to perform the operation "4.3. Rendering a Django Form Field-by-Field," as shown in the example at https://django-formset.fly.dev/single-form/, for {{ form_collection }}, we encounter an error :

AssertionError at /ebildirge/14/
Must be applied to a Form object inheriting from 'django.forms.BaseForm'.
ebildirge_form.html, error at line 36 {% formsetify form %}

Are we missing something? Could you please assist us?
Thank you very much in advance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant