Skip to content

Extended MenuItems not saving to db #146

Open
@mattdjenkinson

Description

@mattdjenkinson

Hey, looking for some help with this plugin.

My extended MenuItems don't save to the DB. I can't see the new columns created in the menu_items table, even after a re-build.

Strapi: 4.15.5
Menus: 1.6.0
DB: mysql
Node: 18.17.0

I have added the strapi-server file;

"use strict";

export default (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 = {
    is_external: {
      type: "boolean",
    },
  };

  // Extend the `MenuItem` content type with custom attributes.
  plugin.contentTypes["menu-item"].schema.attributes = {
    ...defaultAttrs,
    ...customAttrs,
  };

  return plugin;
};

and edited my plugins.ts;

  menus: {
    config: {
      maxDepth: 3,
      layouts: {
        menuItem: {
          link: [
            {
              input: {
                label: "Is External",
                name: "is_external",
                type: "bool",
                description: "Is this a link to an external page?",
              },
              grid: {
                col: 6,
              },
            },
          ],
        },
      },
    },
  },

Not sure what I'm doing wrong 🤔

Any help would be appreciated.

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions