Option to store/return raw value for dropdown
We're having a dropdown so only 1 value can be selected. For us it didn't really matter how the value was saved because we needed the raw value. We chose CSV, but some values in our dropdown contain a comma. The values are stored correct in the database, but the dropdown is not populated. If we there is an option to store the value raw this would fix it for us.
We tried changing the stored value from CSV to XML or JSON, but this means we need to resave all content that's using the dropdown which is too much work. So would it be possible to return the CSV without splitting it?
Topic: https://our.umbraco.org/forum/extending-umbraco-and-using-the-api/78284-nupicker-value-not-prepopulated
Did you guys ever submit this as a PR? We've got the same issue just now, would rather not run with an unofficial version.
Hi @gfyans, yes #150
instead of a Raw format option (as in the PR) fixing #59 should also resolve this issue
Thanks, Hendy. It was actually a colleague who reported having a problem so I'll check in tomorrow with him and update.
Thanks Greg. It would be good to know if it is just commas not being encoded (#59 is more about typeahead)
Hi Hendy, Im Gregs' colleague that is looking into the escaping issue, I had a look at how the values are stored in the umbraco.config and they do not appear to be escaped there:
<schoolTags><![CDATA[[{"key":"School","label":"School"},{"key":"Engineering & Computing","label":"Engineering & Computing"},{"key":"Education","label":"Education"},{"key":"Health, Nursing & Midwifery","label":"Health, Nursing & Midwifery"},{"key":"Media, Culture & Society","label":"Media, Culture & Society"},{"key":"Science & Sport","label":"Science & Sport"}]]]></schoolTags>
We are running 1.5.3 on n Umbraco 7.5.10 install. We are using this data in the nuPickers .NET checkbox picker data type, with values returned as CSV. We are finding that the output of the CSV is splitting items with a comma, so for example 'Health, Nursing & Midwifery' is becoming two items in the CSV: 'Health' and 'Nursing & Midwifery'.
Best L
Hi @Lachlann thanks for the update, looks like the save format above is JSON rather than CSV. JSON should work, but there is an issue with not escaping commas in CSV #59
Hi Hendy, Yeah we tried setting the save type to json but it would have required too big a reworking of our code so i reverted back, the above must have been a hangover from that.
I have taken fork of the repo and amended it to return escaped label values for the csv save type which seems to work well. not sure if it is something you would be interested in me submitting a pull request for?
best L
Hi @Lachlann, if it fixes #59 then a PR would be wonderful ! Ideally we should follow the CSV spec handling commas by putting the field in quotes (and escaping quotes)