sanity-io / sanity-plugin-internationalized-array

A plugin to register array fields with a custom input component to store field values in multiple languages, queryable by using the language ID as an array `_key`.
MIT License
45 stars 11 forks source link

String field with limited possible values (list): “Value did not match any allowed values” #70

Open patrulea opened 6 months ago

patrulea commented 6 months ago

I’m trying to set a string-type field with a dropdown for possible values (list). Though, the input appears to be invalid as it’s expecting a string value but instead getting an object ([object Object]) and it prevents saving the user input.

image

My custom field type looks like this:

// localeSelect.js
export default {
  name: "localeSelect",
  type: "string",
  options: {
    list: [
      {
        title: "English (United States)",
        value: "en_US"
      },
      {
        title: "Spanish (Latin America)",
        value: "es_LA"
      }
    ]
  }
}
// documentSchema.js
{
  name: "locale",
  type: "internationalizedArrayLocaleSelect"
}

Note how there is no custom field validation in place. The string/list field is performing its inherent value check.