Schemas: How to set Initial Value of a Toggle Input to be True by Default

2 replies
Last updated: Sep 19, 2022
hey everyone! i'm having a strange issue with my schema where i'm trying to set the initial value of a toggle input to be
true
by default, but for some reason, it refuses to get set to true. this is my code + a screenshot of what the result is in sanity studio:

{
      title: 'Show Product Reviews',
      name: 'showProductReviews',
      type: 'boolean',
      group: 'shopModule',
      initialValue: true
}
was wondering if anyone had any idea on what's going on or where i went wrong?
Sep 15, 2022, 2:53 PM
Did you change the schema after the document was already created? If I remember correctly the
initialValue
will only be set on documents created after adding that setting to the schema.
Sep 15, 2022, 3:02 PM
Hey
user F
, I think I’ve run into a similar issue that may be the source of some trouble you’re having. Is the parent of the
showProductReviews
boolean a Product created via Sanity Connect for Shopify?
If so, it seems like `initialValue`’s are only set for documents created in the Studio itself.
Sep 19, 2022, 6:52 AM

Sanity.io – build remarkable experiences at scale

Sanity is a customizable solution that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Categorized in