Support

Account

Home Forums Feature Requests Conditional Logic for Clone fields Reply To: Conditional Logic for Clone fields

  • @jongc

    There is a way to do this, but not by using the admin controls and I can’t give you the full code because it would be fairly complicated.

    What you need to do is to alter the conditional logic of the field. This can be accomplished but creating an acr/prepare_field filter for the field in questions. In this filter you would look at $field[‘parent’] and this might let you determine if the field is used in the way you have it set up. If you can, and it is, then you could alter the conditional logic for the field to make it work the way you want it to.

    I have done similar things in the past. This code is an example from a recent project and I use this filter to remove sub fields base on the parent field in some cases.

    
    function remove_fields_on_theme_options($field) {
      
      // remvove some layout fields on options page
      $fields = array(
        'field_5ea2ea8fa0ca2'
      );
      if (in_array($field['key'], $fields)) {
        $parents = array(
          'field_5f32b07ae9253'
        );
        if (in_array($field['parent'], $parents)) {
          return false;
        }
      }
      
      // remove all layout fields and CTA tab inside of quick links
      $fields = array(
        'field_5ea2ea8fa0ca2',
        'field_5eadd1ef885d1',
        'field_5ea5d1d7a83e2',
        'field_5ea5d209a83e3',
        'field_5ddf3c9274fd1'
      );
      $parents = array(
        'field_5f15c8a928f77',
        'field_5f18749c26e32',
        'field_5f1877143d7e0',
        'field_5f32997382af7',
        'field_5f32a577f5900'
      );
      if (in_array($field['key'], $fields) && in_array($field['parent'], $parents)) {
        return false;
      }
      
      return $field;
    }