Skip to content

Instantly share code, notes, and snippets.

@yasudacloud
Created September 29, 2022 17:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yasudacloud/7ac9caf5749f82e2f5391353faf1120e to your computer and use it in GitHub Desktop.
Save yasudacloud/7ac9caf5749f82e2f5391353faf1120e to your computer and use it in GitHub Desktop.
plugin/admin/src/index.tsx
// [plugin]/admin/src/index.tsx
import React from 'react';
import pluginPkg from '../../package.json';
import pluginId from './pluginId';
import Initializer from './components/Initializer';
const name = pluginPkg.strapi.name;
export default {
register(app) {
const options = {
name: "postcode",
pluginId: "ja-postcode",
type: "string",
intlLabel: {
id: "ja-postcode.postcode.label",
defaultMessage: "PostCode",
},
intlDescription: {
id: "ja-postcode.postcode.description",
defaultMessage: "7-digit zip code",
},
icon: null,
components: {
Input: async () => import("./components/PostCode"),
},
options: {
base: [],
advanced: [
{
sectionTitle: {
id: 'global.settings',
defaultMessage: 'Settings',
},
items: [
{
name: 'required',
type: 'checkbox',
intlLabel: {
id: 'form.attribute.item.requiredField',
defaultMessage: 'Required field',
},
description: {
id: 'form.attribute.item.requiredField.description',
defaultMessage: "You won't be able to create an entry if this field is empty",
},
},
{
name: 'private',
type: 'checkbox',
intlLabel: {
id: 'form.attribute.item.privateField',
defaultMessage: 'Private field',
},
description: {
id: 'form.attribute.item.privateField.description',
defaultMessage: 'This field will not show up in the API response',
},
},
],
},
],
}
}
app.customFields.register(options)
const plugin = {
id: pluginId,
initializer: Initializer,
isReady: false,
name,
};
app.registerPlugin(plugin);
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment