How to disable not hide a field hidden by ACF conditional logic

It’s simple enough. Once you set up the ACF conditional fields you can use the ACF JS API to action on an disable_field event. Below we’re letting the city select show but still be disabled so a province select isn’t showing all by itself. We add the event and then set a timeout so that the classes and attributes we are removing are there.

function disabledCity(input){
        window.setTimeout(function(){
          input.$el.removeAttr('hidden').css('display', 'block !important').removeClass('acf-hidden');
        });
      }

      acf.addAction('disable_field/name=agent_brokerage_city', disabledCity);
      acf.addAction('disable_field/name=agent_city', disabledCity);
}

Leave a Reply

Your email address will not be published. Required fields are marked *