Home Forums Backend Issues (wp-admin) Are conditional field settings possible? Reply To: Are conditional field settings possible?

  • Fix for my “Update” issue above:

    In the issue above, Field 3 conditional settings weren’t working appropriately. The fields that were supposed to be hidden where indeed hidden, but the toggle to reveal them no longer revealed them.

    After many hours digging deep into ACF’s javascript and much trial and error, I finally found that calling acf.getField($field) is what is instantiating those fields properly. Why it isn’t working properly in my example, I’m not sure, but here’s the fix:

     *  Fires when duplicating a field from a previously unsaved, duplicated field.
    // Only targeting select fields for this example
    acf.add_action('append_field/type=select', function ($field) {
      // Only target select fields that have my custom class
      if ($field.hasClass('my-custom-class')) {
        // Instantiate hidden sibling fields so conditionals and Select2 UI work