-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Fix 584 #656
Fix 584 #656
Conversation
This allows form submission fields with multiple values to be saved correctly.
There seems to be a Python 3 compatibility issue here. |
This looks like the Python 3 issue: https://docs.python.org/3.1/whatsnew/3.0.html#views-and-iterators-instead-of-lists "Also, the dict.iterkeys(), dict.iteritems() and dict.itervalues() methods are no longer supported." |
data = json.loads(self.form_data) | ||
for k, v in data.iteritems(): | ||
if hasattr(v, '__iter__'): | ||
data[k] = ", ".join(data[k]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This breaks the CSV export. Strings are iterable and they are being printed out as "H", "e", "l", "l", "o", " ", "w", "o", "r", "l", "d"
I've fixed the Python 3 issues. Please could you merge https://github.com/kaedroho/wagtail/tree/mope-584-fix-formbuilder-checkboxes and into this PR and fix #656 (comment) |
I've not had chance to look into this in detail yet, but I have to say I'm not massively keen on the idea of changing the representation of all field types to list, just to fix an issue with one specific field type. Can we look into the feasibility of an option (3) solution? |
Continuing development here: #768 |
Issue
If a form is configured to have a checkbox field with multiple choices and a user submits that form with multiple boxes checked for that field, then only the last box checked will be recorded. This occurs because form data is extracted using the items() method.
Fix
I considered the following approaches:
This pull request implements option (2) for the following reasons:
Disadvantages of this approach: