Support

Account

Home Forums Feature Requests Conditional Logic using Taxonomy field Reply To: Conditional Logic using Taxonomy field

  • Very long thread so sorry if this has already been suggested… but I was wondering about this too and my first thought was… why not use a Select field instead of a Taxonomy field (where conditional logic is already natively supported) and then use some simple PHP to populate the select field. Like this:

    // Programmically Populate an ACF Select Box
    function acf_load_type_field_choices( $field ) {
        $choices = get_terms( 'battery_type', array('hide_empty' => false) );
        if( is_array( $choices ) ) {
            foreach( $choices as $choice ) {
                $value = $choice->slug;
                $label = $choice->name;
                $field['choices'][$value] = $label;
            }
        }
        return $field;
    }
    add_filter('acf/load_field/name=type', 'acf_load_type_field_choices');
    

    This is probably not a great solution though because you have the data in two places not… the taxonomy and the select field. Just a thought. Was hoping to think of a clever solution easier than writing a bunch of JS.