keystone-classic: dependsOn not working at all in .4.x

With the following code, the “school” field does not work at all. This also appears to apply to the String and Types.Text datatypes.

postType: {
    type: Types.Select,
    options: 'news/update, high school, college',
    default: 'news/update',
    index: true
},
school: {
    type: Types.Relationship,
    ref: 'School',
    index: true,
    dependsOn: {   
        postType: ['high school', 'college']
    }
},

Additionally, saving does not make the field appear.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 16 (10 by maintainers)

Most upvoted comments

This is a use case that differs slightly from 0.3.x to 0.4.x. In 0.3.x an Array value is treated as an OR, but in 0.4.x with expression-match it is treated as an AND. So dependsOn is working but returning a false.

The options are: A: Update the docs to reflect using $or for arrays.

dependsOn: {   
        postType: { or:  ['high school', 'college']  }
}

B: Set the default expression as $or in Keystone using the 3rd argument for expression-match.

{ expression: $or }