Custom metadata for a field

Hi,

I’m evaluating strapi against some business requirements, and i’ve got in a bit of a pickle and was wondering if someone could help me. Basically what i need is to apply some custom metadata against different fields, for example, say that a field is part of a specific “category”. ideally i’d like this extra metadata to be able to be defined at design time through the admin ui and included in the API response.

Ideally i would love the ability to add as many of these metadata attributes as i wish and the API to return it.

Any help would be appreciated.

You can achieve this by creating a new custom field:

Hi,

Thanks for this. Had a skim through the documentation and unfortunately the example seems overly complex for my needs, I was expecting a more simple…this is how you add a new custom string field. Was wondering if there’s some simpler guidance around this. I’m mostly interested in changing the way the admin UI is displayed for that field and also the returned schema needs to be altered.

Another question i had was whether there is any limitation around how many custom fields can we add. In our case, we’d most likely require to alter all default fields types.

Cheers

Your needs sound simple but are complex to do and manage them to work properly without conflicting with the existing core functionalities.

You can actually add/modify/delete any field type from the content manager since its code is extensible through extensions. I would recommend looking inside the strapi-plugin-content-manager source code and see how the default fields are created and how their custom attributes are added to the admin.

But please remember that it will be hard to maintain future updates if you use extensions.

Hi,

Thanks for your answer. I’ve been looking through the content manager plugin and found how the default fields (i.e. regex, unique) are displayed, however not sure exactly where to look how these ui elements are wired to the schema.

Also you mentioned extensions, any documentation or examples how to do that?

Cheers,
Andrei

https://strapi.io/documentation/developer-docs/latest/concepts/customization.html#plugin-extensions

Any file that you create in ./extensions/{plugin-name}/ will overwrite the original file from ./node_modules/strapi-plugin-{plugin-name}/. So if you want to modify something in a plugin you just copy the original file into extensions folder and modify it. But you should keep the same directory structure. If you modify something inside the admin folder, then you should rebuild the admin after that or you can run the app with --watch-admin flag, which will detect automatically changes to the admin part and will autobuild it with autoreload.

https://strapi.io/documentation/developer-docs/latest/cli/CLI.html#strapi-develop