-
Notifications
You must be signed in to change notification settings - Fork 162
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
Values for SelectWidget/Select2Widget may not be a generator #385
Comments
@bertjwregeer can you provide a code sample that reproduces this issue? I tried with this example modified from deformdemo, but I think I missed something.
|
You need to submit the form at least once (and validate, but have it fail validation on another form input for instance). At that point when you render the form again the generator will no longer return any values, and all choices will be blank. |
Also, I think I meant |
I modified the
Submit that without entering a value for |
@bertjwregeer I opened a PR for you to try out and review. #469 I couldn't figure out how Deform could save the generated values into a list so it doesn't have to regenerate them on each load/submission. |
If you create a widget with a keyword argument that is a generator for
values
and you validate the form and render the form you will lose all your values in the rendered output as the generator won't be generating anymore.This bit me pretty hard tonight and took me a while to debug, even though I would consider a generator a "a sequence" if one were to look at the documentation.
Maybe it should internally create a list if the incoming type is not a list? Or some other way save the result from
_validate_choices
so that it is computed once instead of each time.The text was updated successfully, but these errors were encountered: