Created
August 16, 2018 02:00
-
-
Save callumflack/4423d07fbabe9997524706bda57627c6 to your computer and use it in GitHub Desktop.
Keystone.js: toggle and display content elements in admin UI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Post = new keystone.List('Post', { . . . }); | |
Post.add({ | |
category: { | |
type: Types.Select, | |
options: ['Post', 'Event', 'Newsletter', 'Resource', 'Job'], | |
default: 'Post', | |
emptyOption: true, | |
}, | |
// if category is Job, show another CMS element (in this case, a dropdown) | |
jobCategory: { | |
dependsOn: { | |
category: 'Job', | |
}, | |
type: Types.Select, | |
options: ['Vacancies', 'Professional development', 'Volunteers'], | |
}, | |
// toggle for showing a CMS element | |
includeClosingImages: Boolean, | |
closingImages: { | |
type: Types.CloudinaryImages, | |
dependsOn: { | |
includeClosingImages: true, | |
}, | |
note: 'Up to 3 images may be set', | |
}, | |
// another toggle example | |
includeButton: Boolean, | |
fileLocation: { | |
type: String, | |
dependsOn: { | |
includeButton: true, | |
}, | |
}, | |
buttonLabel: { | |
type: String, | |
default: 'Download', | |
dependsOn: { | |
includeButton: true, | |
}, | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment