Skip to content

initialValue is marked as invalid incorrectly when schema is composed into a different schema #15

@JodiWarren

Description

@JodiWarren

Say I have an object like:

export default {
  name: "backgroundColour",
  title: "Background Colour",
  type: "colorlist",
  options: {
    list: [
      { title: "Black", value: "#000000" },
      { title: "White", value: "#ffffff" },
    ],
  },
  initialValue: { title: "White", value: "#ffffff" },
  validation: (Rule) => Rule.required(),
}

And I use it in a different schema like so:

export default {
  title: "Page area",
  name: "pageArea",
  type: "object",
  fields: [
  // other fields
    {
      title: "Background Colour",
      name: "backgroundColour",
      type: "backgroundColour",
      initialValue: {
        title: "Black",
        value: "#000000",
      },
      validation: (Rule) => Rule.required(),
    }
  ]
};

the CMS marks the item's value as invalid when it's intialised. I think this is because it adds an additional field of _type, or at least it does when it's console.loged out.

initialValue: {
    title: "Black",
    value: "#000000",
    _type: "backgroundColour",
},

Am I setting the initialvalue incorrectly? Adding the _type doesn't seem to make a difference.

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