verbb / icon-picker

A Craft CMS field to select SVG or font icons from a folder for use in your content.
Other
17 stars 8 forks source link

Cannot save icon field settings for Available Icon Sets in 2.0.0-beta.2 #54

Closed mike-moreau closed 2 years ago

mike-moreau commented 2 years ago

Description

I installed Icon Picker in trial mode in local dev on a Craft 3 site, then I proceed to update Craft to 4.0.4 and Icon Picker to 2.0.0-beta.2.

After updating the Icon Picker Field settings for "Available Icon Sets" are not saving.

Steps to reproduce

  1. Select check boxes for Available Icon Sets on an Icon Picker Field
  2. Save field settings
  3. Visit the field settings after save, checked boxes are not saved.

Additional info

Additional context

"Show Labels" setting seems to work ok

Screen Shot 2022-06-14 at 5 13 44 PM
engram-design commented 2 years ago

Should be fixed in 2.0.0-beta.4

mike-moreau commented 2 years ago

Thank you!! Updating to 2.0.0-beta.4 fixed the field settings issue.

After updating, I got a new type error.

(TypeError(code: 0): in_array(): Argument #2 ($haystack) must be of type array, null given at .../vendor/verbb/icon-picker/src/services/Service.php:358)

This was because $field->remoteSets was NULL.

I was able to resolve it by adding a check for NULL as well as an empty string on line 348 of src/services/Service.php.

if ($field->remoteSets === '' || $field->remoteSets === NULL) {
   return [];
}

Do you think this was a unique case because my settings were not saving correctly before? Or would you like me to submit a PR for this additional NULL check?

engram-design commented 2 years ago

Sorry, I should've updated that link as I've made a few more fixes today (including that bug). Take a look at 2.0.0-beta.5

mike-moreau commented 2 years ago

Great, thanks again.