You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What I see happening is that after you select a value (potentially having to click on dummy to get some round trips going) the forms.ChoiceField causes djanog_unicorn.components.unicorn_view.UnicornView.get_frontend_context_variables to use the django.forms.widgets.ChoiceWidget.format_value in a call like value = field.widget.format_value(cleaned_value) which forces this string into an array, "['FIRST_CHOICE"]" for example. I think I have a workaround to set the widget on the form field manually to something else other than the ChoiceWidget (maybe a TextInput or something else less custom than ChoiceWidget) and that seems to fix it. I don't know yet what I'd propose as a fix, but am I missing anything in this setup that I should be doing differently? I suppose all the widgets for form.Fields are not useful if we create a unicorn template without them.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I think I've had some issues working with forms.ChoiceField. Basically if you have something like this:
And a template something like this:
What I see happening is that after you select a value (potentially having to click on dummy to get some round trips going) the forms.ChoiceField causes djanog_unicorn.components.unicorn_view.UnicornView.get_frontend_context_variables to use the django.forms.widgets.ChoiceWidget.format_value in a call like
value = field.widget.format_value(cleaned_value)
which forces this string into an array, "['FIRST_CHOICE"]" for example. I think I have a workaround to set the widget on the form field manually to something else other than the ChoiceWidget (maybe a TextInput or something else less custom than ChoiceWidget) and that seems to fix it. I don't know yet what I'd propose as a fix, but am I missing anything in this setup that I should be doing differently? I suppose all the widgets for form.Fields are not useful if we create a unicorn template without them.Beta Was this translation helpful? Give feedback.
All reactions