From 0530e0ca4ea7f0ba62e6be4d763e6c70f777b596 Mon Sep 17 00:00:00 2001 From: Otu Ekanem Date: Fri, 19 Mar 2021 17:48:40 +0100 Subject: [PATCH 1/5] updated select name attribute to use field.html_name When using any of the `formset_factory`s to generate multiple forms, the select fields lose their values if the form is returned with an error. This happens because the template renders `field.name` instead of `field.html_name`. `field.name` is the same for all forms, `field.html_name` is unique for each form instance --- crispy_tailwind/templates/tailwind/layout/select.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crispy_tailwind/templates/tailwind/layout/select.html b/crispy_tailwind/templates/tailwind/layout/select.html index 3266993..ae784f5 100644 --- a/crispy_tailwind/templates/tailwind/layout/select.html +++ b/crispy_tailwind/templates/tailwind/layout/select.html @@ -2,7 +2,7 @@ {% load l10n %}
- {% for value, label in field.field.choices %} {% include "tailwind/layout/select_option.html" with value=value label=label %} {% endfor %} From f3b2a403333bcffee77dce0dd754a7ccf2782577 Mon Sep 17 00:00:00 2001 From: Otu Ekanem Date: Fri, 19 Mar 2021 17:56:48 +0100 Subject: [PATCH 2/5] fixed tests for bug fix related to formset_factor form select --- tests/test_table_inline_formset.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_table_inline_formset.py b/tests/test_table_inline_formset.py index 3aab11c..6e86316 100644 --- a/tests/test_table_inline_formset.py +++ b/tests/test_table_inline_formset.py @@ -105,7 +105,7 @@ def test_table_inline_formset(self):
- @@ -181,7 +181,7 @@ def test_table_inline_formset(self):
- From 284734a2040b74476489b42da69b703c906b44d8 Mon Sep 17 00:00:00 2001 From: Otu Ekanem Date: Fri, 19 Mar 2021 18:02:49 +0100 Subject: [PATCH 3/5] silly billy / fixed the test --- tests/test_table_inline_formset.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_table_inline_formset.py b/tests/test_table_inline_formset.py index 6e86316..517f4f9 100644 --- a/tests/test_table_inline_formset.py +++ b/tests/test_table_inline_formset.py @@ -105,7 +105,7 @@ def test_table_inline_formset(self):
- From b4ec6318a34c2cb7de38ce1f01d789670d922e56 Mon Sep 17 00:00:00 2001 From: Otu Ekanem Date: Tue, 23 Mar 2021 18:37:14 +0100 Subject: [PATCH 4/5] fixed bug which caused bound forms to lose selected option in forms.ModelForm types, the `select > option` value attribute is usually set to the primary key of the model object (usually an int) This commit converts `field.value` to string to ensure the `if` condition for adding selected to the