Persisting custom field data

System Information
  • Strapi Version: 3.5.4
  • Operating System: Mac OSX
  • Database: Mongo
  • Node Version: 14.16
  • NPM Version: 6.14.11

So I have created a custom field plugin and I have modified my content-type model to use it. It’s a google maps plugin:

strapi.registerField({ type: 'map', Component: MapsWrapper })

"Location": {"type": "map","required": true},

However, when I try to save the data json object I send through onChange() it does not seem to persist to the mongo database entry. Do I need to make a custom model for this field and if so can someone point me in the right direction on how to do so?

The only solution I have seen so far, is to serialize the JSON into a string and save it as a longtext. E.g. GitHub - paulgaumer/Strapi_ColorPicker_Plugin

This requires to manually set columnType to longtext: Strapi_ColorPicker_Plugin/Category.settings.json at 7f1580dfa00098c930d7590cf6b3bad3f74bffc8 · paulgaumer/Strapi_ColorPicker_Plugin · GitHub

In case you find a better solution, please let me know :slight_smile:

@gustavpursche Thanks this worked for me i just had to use String instead because im dealing with mongoose types. I also tried using object and map but those didn’t work either. So im just gonna parse and stringify for now.

1 Like

Hi @starrett67, I’m actually searching for this same Map Custom field. Would it be possible for you to share your plugin?