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
Since it's often nice to be able to display text options that don't perfectly match the desired form submission values, and python comes with a pretty nice JSON parser built in, adding the ability to enter form field choices as JSON-formatted text would be nice. This would require an additional setting option to be configured, and could be served by the following code modifcation in forms_builder.forms.models at line 202.
defget_choices(self):
""" Parse a comma separated choice string into a list of choices taking into account quoted choices using the ``settings.CHOICES_QUOTE`` and ``settings.CHOICES_UNQUOTE`` settings. """ifnotsettings.USE_JSON_CHOICES:
choice=""quoted=Falseforcharinself.choices:
ifnotquotedandchar==settings.CHOICES_QUOTE:
quoted=Trueelifquotedandchar==settings.CHOICES_UNQUOTE:
quoted=Falseelifchar==","andnotquoted:
choice=choice.strip()
ifchoice:
yieldchoice, choicechoice=""else:
choice+=charchoice=choice.strip()
ifchoice:
yieldchoice, choiceelse:
importjson# noaqparsed=json.loads(self.choices)
try:
forvalue, choiceinparsed.items():
yieldvalue, choiceexceptAttributeError:
ifnotisinstance(parsed, basestring):
forchoiceinparsed:
yieldchoice, choiceelse:
yieldparsed, parsed
The text was updated successfully, but these errors were encountered:
Since it's often nice to be able to display text options that don't perfectly match the desired form submission values, and python comes with a pretty nice JSON parser built in, adding the ability to enter form field choices as JSON-formatted text would be nice. This would require an additional setting option to be configured, and could be served by the following code modifcation in forms_builder.forms.models at line 202.
The text was updated successfully, but these errors were encountered: