nuPickers icon indicating copy to clipboard operation
nuPickers copied to clipboard

Option to store/return raw value for dropdown

Open jbreuer opened this issue 9 years ago • 10 comments

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?

jbreuer avatar Sep 28 '16 08:09 jbreuer

Topic: https://our.umbraco.org/forum/extending-umbraco-and-using-the-api/78284-nupicker-value-not-prepopulated

jbreuer avatar Sep 28 '16 08:09 jbreuer

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.

gfyans avatar Mar 06 '17 14:03 gfyans

Hi @gfyans, yes #150

Hendy avatar Mar 06 '17 19:03 Hendy

instead of a Raw format option (as in the PR) fixing #59 should also resolve this issue

Hendy avatar Mar 06 '17 19:03 Hendy

Thanks, Hendy. It was actually a colleague who reported having a problem so I'll check in tomorrow with him and update.

gfyans avatar Mar 06 '17 19:03 gfyans

Thanks Greg. It would be good to know if it is just commas not being encoded (#59 is more about typeahead)

Hendy avatar Mar 06 '17 20:03 Hendy

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

Lachlann avatar Mar 07 '17 11:03 Lachlann

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

Hendy avatar Apr 04 '17 19:04 Hendy

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

Lachlann avatar Apr 05 '17 08:04 Lachlann

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)

Hendy avatar Apr 05 '17 08:04 Hendy