In a custom module, I have a field that I want to make required, but only if another field on the form has a certain value. The field that I want validated appears only when the user selects an appropriate option from the other field, which is represented visually by a dropdown. That part works, but I also want to add validation. Is there any way to do that in the UI? I know, as a workaround, I can add an event hook, but I'd like to keep this logic all in one place, i.e. in the module>class>form editor.
If you’re using the Visibility condition, then you should be able to just mark the field as required. Kentico will not render the control of the Visibility condition is not met.
There is a good article by Jan about how to work with depending fields which might be worth reading through.
That may work if I set a default value. From what I've seen, fields that are marked as required are set to not allow nulls in the DB, so without a default value, an insert would fail regardless of the visibility condition.
Did you ever find an answer to this?
@Kàren, No, I don't think I pursued it further.
Please, sign in to be able to submit a new answer.