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

Icon picker field using Remote Icon Set loses all field values on update to 2.x #62

Closed corneliusio closed 1 year ago

corneliusio commented 1 year ago

Describe the bug

Upgrading a site from Craft 3.7.59 to 4.3.4 and Icon Picker from 1.1.14 to 2.0.7 with a Icon Picker field that was only set to use the "Font Awesome 5 (All)" remote set resulted in all icon fields losing their values. It appears that the plugin assumed there to be a icon folder and created the default [root] set as an SVG Folder. Replacing this default set with a new set for the Font Awesome CDN did not restore any values.

As an aside, if I attempt to change the type of an existing set I usually get an error about setting an unknown property. For example, changing a Font Awesome source to an SVG Folder source throws Setting unknown property: verbb\iconpicker\iconsets\SvgFolder::apiKey and the reverse results in Setting unknown property: verbb\iconpicker\iconsets\FontAwesome::folder.

Steps to reproduce

  1. Configure pre-2.x Icon Picker field to use a remote set.
  2. Upgrade to ^2.0 version of Icon Picker

Craft CMS version

4.3.4

Plugin version

2.0.7

Multi-site?

No

Additional context

No response

engram-design commented 1 year ago

So remote sets are a bit of a pain to migrate, because they are so different.

The values are still there. and migrated across (you should be able to confirm in your content tables have a value), but because the icon set isn't created, it's not migrated properly. There's also the tricky part that we now need to include the collection prefix fab, fas, etc which we didn't record in Icon Picker 1.

So firstly, create a new Font Awesome icon set (CDN, v5, free, all collections), with the handle font-awesome-all (which was the previous handle for the remote set). The latest version handles adding this for you during migration. Unfortunately, because you've already migrated, we've dropped the reference to the remote icon set setting for the field, so this will need to be manual.

You'll then need to install the latest version as below which adds a further conversion for field values to convert what was stored as anchor to fa fa-anchor (for example).

The only downside of this is that the label of the field will show Fa Fa Anchor as they'll be based off their value. Icon Picker 2 will save more data about the icon, including a nicer label, so you'll have to go through and manually re-add those icons via the icon picker (opening the picker, typing anchor, select and update entry). This is purely cosmetic though, as the icon value will work just fine on the front-end, and in the field. It'd just be nice to have it say Anchor instead.

Also fixed the issue when switching between types.

Hope that makes sense, sorry for the trouble - see 2.0.8