The Wayback Machine - https://web.archive.org/web/20201206124609/https://github.com/coderedcorp/coderedcms/issues/166
Skip to content
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

Allow commas in comma separated form choices #166

Open
vsalvino opened this issue Apr 17, 2019 · 3 comments
Open

Allow commas in comma separated form choices #166

vsalvino opened this issue Apr 17, 2019 · 3 comments

Comments

@vsalvino
Copy link
Contributor

@vsalvino vsalvino commented Apr 17, 2019

It is a common use-case to require a comma in a form choice, such as "Please specify your income: $1,000 - $2,000" etc. I think it would be preferable to use pipe separator since it is not an English grammatical character.

While we do have a very customized form page, we are still leaning on some underpinnings of wagtail.contrib.forms, so I think we will either need to provide our own choice field, or make a contribution to wagtail to support changing it from the hard-coded comma.

@vsalvino
Copy link
Contributor Author

@vsalvino vsalvino commented Apr 24, 2019

A nice backwards-compatible workaround that I manually implemented on a previous site: simply override the radio/checkbox/choice fields to be pipe delimited if they contain a pipe, otherwise behave as usual (comma delimited).

@vsalvino vsalvino removed this from the 0.15.0 milestone Jun 3, 2019
@aniketsonu
Copy link

@aniketsonu aniketsonu commented Oct 16, 2020

Hi, @vsalvino where are we using this exactly? I've just set up the environment and was going through the documentation

@vsalvino
Copy link
Contributor Author

@vsalvino vsalvino commented Oct 16, 2020

In the Wagtail admin, create a Form Page. Then, while adding fields, if you add a dropdown, checkbox, radio (any kind of multi-select) there is a text/char field for choices. This char field expects comma delimited choices.

For example, the text: 1, 2, 3
Would render as:

[ ] 1
[ ] 2
[ ] 3

HOWEVER - if you need an option containing a comma, it is currently not possible. As a workaround, separating items with a PIPE character | would be an alternative. If the pipe character exists in the char field, use it as the delimiter. Otherwise, use comma.

For example: 1,000 | 2,000 | 3,000
Would render as:

[ ] 1,000
[ ] 2,000
[ ] 3,000

The code would need to be added to CoderedFormBuilder to extend built-in functionality in Wagtial's FormBuilder, when creating dropdown, multiselect, radio, etc. fields.

class CoderedFormBuilder(FormBuilder):
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.