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.
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
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:
- on the
featuredfield, present the user with a checkbox
- when the user checks the box, check the headline and image fields
- if the headline and image fields are filled out, set the value of the featured field to true
- 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: