jrief / django-formset

The missing widgets and form manipulation library for Django
https://django-formset.fly.dev/
MIT License
317 stars 30 forks source link

loosing borders in selectize widget after pressing button "Reset to initial" in bootstrap mode #122

Closed amikphoto closed 5 months ago

amikphoto commented 5 months ago

I've a form with selectize widget (foreing key). When the form is opened I press on "Reset to initial" button this fiels loosing border and style. Is it bug?

lsmoker commented 5 months ago

I am also seeing an error when doing this. The SelectizeMultiple widget becomes inactive after clicking the Reset button. The console prints "Bad Request: my_url_path". The problem appears to be in formset/collection.py - https://github.com/jrief/django-formset/blob/0ec769546d6c241a4e10f29ef0caafe4d4b9e379/formset/collection.py#L490

The field_path value is in the format: books.0.book.authors

So the path var becomes 0.book.authors which causes an error since that field can't be found.

The collection/form nesting looks like this (from top to bottom): LibraryCollection which includes BookCollection which includes BookForm which includes a SelectizeMultiple widget for authors

jrief commented 5 months ago

Thanks for reporting. I'll have a look at this.

jrief commented 5 months ago

@amikphoto I just tested on the demo page. What I see here, after clicking "Reset to initial" the field named "Static Opinion" forgets about all its options. However, I do not see the field losing its borders. How can I reproduce this?

jrief commented 5 months ago

I now fixed the problem with Reset on the Selectize widget with "Static Opinion".

However, I am not able to reproduce the field losing its borders.

amikphoto commented 5 months ago

Thank you very much for your work! But finally It seems to me the main problem of Selectize widget is in formset collections. When I try to use Selectize widget in form collection and when I start input letters for serach in the form I have the same problem as Lsmoker . The same problem is when I press "Reset to initial". I can't say exactly but it seems to me the problem is the reason of loosing css style (borders).

jrief commented 5 months ago

But finally It seems to me the main problem of Selectize widget is in formset collections.

This was the missing information. Now I am able to reproduce this myself.

amikphoto commented 5 months ago

But finally It seems to me the main problem of Selectize widget is in formset collections.

This was the missing information. Now I am able to reproduce this myself. I'm sorry to disturd you but just ask :) Did you find the problem? Could I hope to use Selectize in collections soon?

jrief commented 5 months ago

I'm sorry to disturd you but just ask :) Did you find the problem? Could I hope to use Selectize in collections soon?

I just pushed a working solution. I have to fix some unit tests before releasing a new version.

amikphoto commented 5 months ago

Thank you very much!

amikphoto commented 5 months ago

Still have the problem with new release 1.3.9. It happened when I use selectize widget and when I use active search in the widget and it tries to get answer from backend to get new list of options.

The problem appears in:

class FormCollection(BaseFormCollection, metaclass=FormCollectionMeta): """ Base class for a collection of forms. Attributes of this class which inherit from django.forms.forms.BaseForm are managed by this class. """ def get_field(self, field_path): path = field_path.split('.', 1) key, path = path return self.declared_holders[key].get_field(path)

image

self.declared_holders[key].get_field(path) return KeyError:'0'