acf-color-palette icon indicating copy to clipboard operation
acf-color-palette copied to clipboard

Console Error message when "Choice" attribute is not setted

Open be2ny opened this issue 6 years ago • 2 comments

Hi ! Thanks for your contribution and your plugin, i use it for many projects. So I open an issue because I created a Color-palette for test in local environment and I've forgot to set default choice like this :

#f00 : Red rgb(0,255,0) : Green rgba(0, 0, 255, 1) : Blue

I saved the custom field and I was editing an article to use it, and I had a console error:

SyntaxError: "JSON.parse: unexpected character at line 1 column 1 of the JSON data" TypeError: n.palettes.map is not a function

So I think that it would be necessary to check the field "Choice" in ACF before the save to avoid this kind of errors.

Thanks for your work and your time.

be2ny avatar Jan 18 '19 09:01 be2ny

Hi @be2ny, Thank you to point out this problem. It's a bit stupid but I didn't think to save the field without any value :sweat_smile:

We can resolve the problem in two steps :

  1. Throw an error into ACF page if the field is required;
  2. Display a warning message into post editing page if the field hasn't any value.

I hope you will appreciate this solution. I will try to fix this issue during the week.

7studio avatar Jan 22 '19 13:01 7studio

What about a global setting for a "default" color?

mtruitt avatar Oct 14 '19 16:10 mtruitt