I hava a template that creates a checkbox and a text input field:
@helper.checkbox(inputForm("live"), 'checked -> true, 'onclick -> "hideTextFields()")
@helper.inputText(inputForm("target"), 'disabled -> true)
When unchecking the checkbox, the text fields get visible (and vice versa). This is done in a javascript function called hideTextFields().
Now, in the controller I need to have a constraint, that makes the text input field mandatory as soon as the checkbox is unchecked.
I have a mapping:
"live" -> boolean
"target" -> nonEmptyText
but this always requires the target to be specified.
How can I achieve dynamic constraints for the text input field based on the checkbox's state. Play is version 2.3.4.
Thank you and best regards!