It is ok, good practice to add/remove bindings on a Binder depending on the state of the form?

Hi,

I have a form, to put it simply it has an optional part that it gets enabled (= becomes required) by for example a checkbox on the main form and I add/remove bindings for the fields on that part depending on that state, for example, pseudo code:

public void on(){
   
    optionalFieldBinding = binder.forFiend(...).asRequired(...).validator(....) etc etc;
}

public void off(){
   
   if(optionalFieldBinding != null){

    optionalFieldBinding.setAsRequiredEnabled(false);
    binder.removeBinding(optionalFieldBinding);
    optionalFieldBinding = null;
   }
}

It seems to work from my test, I am just asking if it’s ok to add/remove bindings from fields or there are come caveat.

Thanks for the help.

P.S. I am using V14

It’s normal and intended

ok nice then, thanks

There are even nuances to this. You can either completely remove binding, or you can just turn off validators of a specific binding. I can envision use cases for both.

@yummy-rhino I was looking at BindingsAPI yes I can use setValidatorsDisabled(..) too… is unbind in Binding the same as binder.removeBinding(...)?