form_choices "not a valid choice"
See original GitHub issue form_choices = {'pref1': [(1, 'Offensive Lineman'), (2, 'Wide Receiver'), (3, 'Offensive Lineman OR Wide Receiver')],
'pref2': [(1, 'Yes'), (2, 'No'), (3, 'Depends')], 'pref3': [(1, 'Yes'), (2, 'No')],
'pref4': [(1, 'Yes'), (2, 'No')], 'timezone': [(1, 'EST'), (2, 'CST'), (3, 'PST'), (4, 'Europe')],
'role': [(2, 'QB'), (1, 'Veteran'), (0, 'Rookie'),]}
They are ints in the database, so I’m not sure why it isn’t working when trying to change any of these form values.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:5
Top Results From Across the Web
WTF.forms "Not a Valid Choice" error for SelectField ...
The problem is that when I submit the form I receive a "Not a valid choice" for these 3 fields. I followed this...
Read more >Solved: Unable to match form choices to sharepoint list
Solved: I am trying to setup a Flow to pull responses from a MS Form response and post them to a sharepoint list....
Read more >Form choice field not working, 'Select a valid choice' error
Hi all, when I select an option from my dropdown list I get the following error: Select a valid choice. 94 is not...
Read more >Common Editing Properties - jqGrid
formoptions (valid only in form editing) ... is a boolean and can have a value of true or false. The option defines whether...
Read more >[Solved]-Ordering CharField form choices in Django-django
Coding example for the question Ordering CharField form choices in Django-django. ... Error: Select a valid choice. ... is not one of the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Well, it can be achieved via
form_args
property, see below:First import:
Then override field and map your form field:
Also, if you want to alias your column in listing then do the following:
I had this bug as well. It’s because the values coming back from the form are strings (like
"1"
) not integers.I’m not sure if my solution is the best one - I think there are probably alternatives, but here’s what I did: I overrode the
validate_form
method to cast the value I needed (to avoid the error). I also had to override theon_form_prefill
method to do the reverse conversion - otherwise the selected option wasn’t pre-selected in the drop-down on the edit form.Here’s an adapted example for a field called
pref1
. You’d need to extend this to handle all the fields in your code sample, @ToastyBiggums.