SpeakInCode
3/7/2020 - 8:45 PM

Conditional Field Settings

<?php

// Show either the Button Text or Button Icon field setting
acf_render_field_setting($field, [
    'label'        => __('Button Type', 'acf'),
    'instructions' => '',
    'type'         => 'button_group',
    'name'         => 'button_type',
    'layout'       => 'horizontal',
    'choices'      => [
        'text' => __('Text', 'acf'),
        'icon' => __('Icon', 'acf')
    ]
]);

// Only show if Button Type field setting is set to Text
acf_render_field_setting($field, [
    'label'        => __('Button Text', 'acf'),
    'instructions' => '',
    'type'         => 'text',
    'name'         => 'button_text',
    'conditions'   => [
        'field'    => 'modal_button_type',
        'operator' => '==',
        'value'    => 'text'
    ]
]);

// Only show if Button Type field setting is set to Icon
acf_render_field_setting($field, [
    'label'        => __('Button Icon', 'acf'),
    'instructions' => 'Select an Icon',
    'type'         => 'text',
    'name'         => 'button_icon',
    'conditions'   => [
        'field'    => 'modal_button_type',
        'operator' => '==',
        'value'    => 'icon'
    ]
]);