Closed wdmtech closed 1 year ago
Hey there, I have added a couple of relation fields, and curiously the dropdowns for the Pages content-type use id but the ones for Authors use name
id
name
Does anyone know if there any way of specifying which field to use, or where the plugin pulls this field from?
Here's how I'm adding the fields:
Schema extension:
// ./src/extensions/menus/strapi-server.js "use strict"; module.exports = (plugin) => { // Get current `MenuItem` attributes. const defaultAttrs = plugin.contentTypes["menu-item"].schema.attributes; // Define custom attributes for `MenuItem` the same way they would be defined // on any other schema. const customAttrs = { example_bool: { type: "boolean", }, example_media: { type: "media", allowedTypes: ["images"], multiple: false, }, pages: { type: "relation", relation: "oneToMany", target: "api::page.page", }, categories: { type: "relation", relation: "oneToMany", target: "api::category.category", }, authors: { type: "relation", relation: "oneToMany", target: "api::author.author", }, }; // Extend the `MenuItem` content type with custom attributes. plugin.contentTypes["menu-item"].schema.attributes = { ...defaultAttrs, ...customAttrs, }; return plugin; };
Form layout extension:
// ./config/plugins.js "use strict"; module.exports = { menus: { config: { maxDepth: 3, layouts: { menuItem: { link: [ { input: { label: "Boolean", name: "example_bool", type: "bool", }, grid: { col: 6, }, }, ], media: [ { input: { label: "Media", name: "example_media", type: "media", }, }, ], pages: [ { input: { label: "Pages", name: "pages", type: "relation", }, }, ], categories: [ { input: { label: "Categories", name: "categories", type: "relation", }, }, ], authors: [ { input: { label: "Authors", name: "authors", type: "relation", }, }, ], }, }, }, }, };
I changed the label from pages to something else (and back again), and now it is using the name field - I have no idea how, but all works as expected now!
Hey there, I have added a couple of relation fields, and curiously the dropdowns for the Pages content-type use
id
but the ones for Authors usename
Does anyone know if there any way of specifying which field to use, or where the plugin pulls this field from?
Here's how I'm adding the fields:
Schema extension:
Form layout extension: