Validation based on other fields

Is there a way to add validation that depends on other fields? For example, if an Article’s featured field is checked/true, require the headline and image fields.

Hi @jwicks,

We recently answered that question in a similar thread:

In a nutshell, we don’t have a native validation mechanism based on the input of different fields, but you could achieve that by using our UI extension SDK and writing a bit of code :slight_smile:

Hope this helps!

A UI extension is the way to go. Add a featured field to the Article content type and set the required validation. Then make a UI extension where the logic would be:

  1. on the featured field, present the user with a checkbox
  2. when the user checks the box, check the headline and image fields
    1. if the headline and image fields are filled out, set the value of the featured field to true
    2. if the headline and image fields are not filled out, present the user with an error message

because it is required and you are selectively filling out the field based on the state of other fields, the entry can’t be published unless the featured article field is filled out. For more details check out these links: