1👍
✅
There’s no simple way to do this. You’ll need Javascript and custom validation on the server.
Using jQuery, the client code might look like this:
var F2_CHOICES = {
'a' : { 'c' : 'c', 'd' : 'd'},
'b' : { 'e' : 'e', 'f' : 'f'}
};
var $field2 = $('[name=field2]');
$('[name=field1]').change(
function() {
var currentValue = $(this).val() ;
$field2.empty();
for (o in F2_CHOICES[currentValue]){
$field2.append('<option '+' value="'+o+'">'+F2_CHOICES[currentValue][o]+'</option>');
}
});
On the server, you’ll need to define a clean
method on your form to check if field2 value is one of the choices that correspond to field1 value.
Source:stackexchange.com