Support

Account

Forum Replies Created

  • This helped me immensely. God bless you. Here’s a solution using a repeater field as one of the fields to confirm a total of 100%, in case it helps anyone.

    add_filter('acf/validate_value/key=field_582494bd7b140', 'my_validate_function', 10, 4);
    
    function my_validate_function($valid, $value, $field, $input) {
    	
    	// bail early if value is already invalid
    	if( !$valid ) {
    		
    		return $valid;
    		
    	}	
    	
    	$mv_commission 		= $_POST['acf']['field_582494bd7b140'];
    	$vendor_commission	= $_POST['acf']['field_58249ac80b697'];
    	$other_commissions	= $_POST['acf']['field_582492287b13c'];
    	
    	if ( is_array($other_commissions) ) {
    		foreach($other_commissions as $commission){
    			$other_total += $commission['field_582494367b13e'];
    		}
    	}
    
    	$commission_total = $mv_commission + $vendor_commission + $other_total;
    	
    	if ( $commission_total !== 100 ) {
    		return "Error: The total commissions for a voucher must equal 100%. The total commissions set on this voucher currently equal $commission_total%.";
    	}
    
    	return $valid;
    
    }
  • Thank you, @iamntz! That got me pointed in the right direction. Also for some reason enqueuing the script didn’t work. I had to use inline scripts from my functions.php file.

  • It sounds like it is storing it as a string if there’s only one value. To test, you could try something like this:

    if ( is_array($values) ) {
        foreach($values as $val) {
            echo "<p>{$val}</p>";
        }
    } else {
        echo "<p>{$value}</p>";
    }
  • Have you tried using the help documents? Here’s a great post with PHP examples: http://www.advancedcustomfields.com/resources/relationship/

    <?php 
    
    $posts = get_field('relationship_field_name');
    
    if( $posts ): ?>
        <ul>
        <?php foreach( $posts as $post): // variable must be called $post (IMPORTANT) ?>
            <?php setup_postdata($post); ?>
            <li>
                <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
                <span>Custom field from $post: <?php the_field('author'); ?></span>
            </li>
        <?php endforeach; ?>
        </ul>
        <?php wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly ?>
    <?php endif; ?>

    Or are you trying to do this without any custom coding?

  • I figured out my issue, in case this helps anyone. I used the sample code found here: http://www.advancedcustomfields.com/resources/google-map/ to generate a map. I grouped more than one using tabs (which uses jQuery UI’s tabs) and initiated it like so:

    $('.acf-map').each(function(){
        render_map( $(this) );
    });

    That left me with a map in each tab. The problem was, the hidden maps (in inactive tabs) didn’t fully render (only the top left block would be showing). There is likely a better way to do this, but I stored the javascript map variable so I could use it again, then listened for tab clicks so I could redraw the map like so:

    $( ".my-tabs" ).on( "tabsactivate", function( event, ui ) {
        var map = jQuery.data(document.body,"map");
        //resize the map    
        google.maps.event.trigger(map, 'resize');
        //center the map
        center_map( map );
    });

    This worked for me. I realize this isn’t an ACF “problem”, but it might be helpful to users to have it in the docs just in case they run into it.

    Cheers!
    Jay

  • This reply has been marked as private.
  • Hey @Elliot Condon,

    This issue is happening for me. Google map inside a tab. Here’s a sample:

    http://logans.linkhousedev.net/death-notice/bob-jacklin/

    Scroll to Service & Visitation, and click the VISITATION LOCATION tab.

    Thoughts?

Viewing 7 posts - 1 through 7 (of 7 total)