Skip to content
KeystoneJS LogoKeystoneJSv5

Select

Usage

keystone.createList('Orders', {
  fields: {
    status: { type: Select, options: 'pending, processed' },
  },
});

Config

OptionTypeDefaultDescription
options*nullDefines the values (and labels) that can be be selected from, see below
isRequiredBooleanfalseDoes this field require a value?
isUniqueBooleanfalseAdds a unique index that allows only unique values to be stored

options

The options config can be supplied as either:

  • A comma-separates list of values, eg: 'Pending, Processed, Errored'
  • An array of strings, eg: ['ready', 'sent', 'deleted']
  • An array of objects, each specifying an value and label, eg:
const options = [
  { value: 'YES', label: "Yes, I'll be there!" },
  { value: 'NO', label: "Sorry, I can't make it :(" },
  { value: 'MAYBE', label: 'Not sure yet' },
];

keystone.createList('Rsvp', {
  fields: {
    attending: { type: Select, options },
    // ..
  },
});

Have you found a mistake, something that is missing, or could be improved on this page? Please edit the Markdown file on GitHub and submit a PR with your changes.

Edit Page