基本上是标题所说的-我们正在一个项目中,我们希望能够根据其他字段的值来显示和隐藏各个字段。这似乎是possible in KeystoneJS 4,但我在KeystoneJS 5中看不到它。
答案 0 :(得分:2)
dependsOn
功能尚未实现最新的KeystoneJs迭代。 v5(我们称为它)已完全重写,并且没有v4的许多功能。
尽管有Pull Request可能会添加此功能,但不幸的是,这并不是核心团队的优先考虑,他们也没有对PR做出回应。
公关合并后,您可以执行以下操作
keystone.createList('Test field', {
fields: {
price: { type: Decimal, symbol: '$' },
currency: { type: Text, dependsOn: { $lt: { price: 3 } } },
hero: { type: File, adapter: fileAdapter, dependsOn: { $gt: { price: 3 } } },
markdownValue: { type: Markdown, dependsOn: { $gt: { price: 6 } } },
fortyTwo: {
type: Virtual,
graphQLReturnType: `Int`,
resolver: () => 42,
},
}});