Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
JodiWarren opened this issue Sep 13, 2021 · 0 comments

Comments

@JodiWarren
Copy link

JodiWarren commented Sep 13, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant