为keystoneJS

时间:2016-05-07 04:02:10

标签: javascript mongoose keystonejs

如何为嵌套字段设置'dependsOn'?

这不会起作用......

Model.add({
    title:          { type: String, required: true },
    test1:          { type: Boolean, default: false },
    verify1:        { type: String, dependsOn: { test1: false } },
    nested: {
        test2:      { type: Boolean, default: false },
        verify2:    { type: String, dependsOn: { test2: false } },
    }
});

1 个答案:

答案 0 :(得分:2)

我尝试了一些事情。您不仅需要包含路径,还必须将其视为字符串。

这有效......

Model.add({
    title:          { type: String, required: true },
    test1:          { type: Boolean, default: false },
    verify1:        { type: String, dependsOn: { test1: false } },
    nested: {
        test2:      { type: Boolean, default: false },
        verify2:    { type: String, dependsOn: { 'nested.test2': false } },
    }
});