Support

Account

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

  • Ok Guys, my solution:

    	function my_acf_admin_head() {
    		global $post_type;
    		if( 'midias_type' == $post_type ) : ?>
    		<script type="text/javascript">
    			(function($){
    
    				acf.add_action('ready', function( $el ){
    
    					var container = $('.acf-field');
    					var $field = $('.acf-checkbox-list input');
    
    					container.each(function ( index) {
    						if(!$(this).hasClass('acf-field-taxonomy')) {
    							$(this).addClass("hidden-by-conditional-logic");
    						}
    					});
    
    					$field.on('click', function (evt) {
    						var ele = $(this).val();
    						container.removeClass('hidden-by-conditional-logic');
    						if(ele == '53') {
    							$('[data-name="arquivo"]')
    									.siblings(':not(.acf-field-taxonomy,[data-name="capa"])')
    									.addClass('hidden-by-conditional-logic');
    						} else if(ele == 52) {
    							$('[data-name="fotos"]')
    									.siblings(':not(.acf-field-taxonomy)')
    									.addClass('hidden-by-conditional-logic');
    						} else if(ele == 51) {
    							$('[data-name="video"]')
    									.siblings(':not(.acf-field-taxonomy,.acf-field-text)')
    									.addClass('hidden-by-conditional-logic');
    						}
    					});
    
    					$('input[type="radio"]:checked' ).click();
    				});
    
    			})(jQuery);
    		</script>
    		<?php endif;
    	}
    
    	add_action('acf/input/admin_head', 'my_acf_admin_head');