Support

Account

Forum Replies Created

  • Any way to sollve this ? hte previews modification on the core doesn’t work wil multiple map on the same page.

  • The only workaround to fix this is modifying the core of ACF.

    File assets/js/acf-input.js
    Changing this :
    this.$search().val( val.address );
    for this:
    this.$search().val(this.$input.val());

    Is this a bug or am i missing something.

  • well I tried all the possibilities without luck…
    So to fix this I used the update_post_meta function.

    $addresses = get_field( 'company', $post_id  );
    $counter = 0;
    foreach ( $addresses as $key => $address) {
    	foreach ($address as $k => $adr) {
    		$field = 'company_addresses_' . $counter . '_address_';
    		$counter++;
    		if( $adr['address']['geocode'] ){
    			$gaddress = $adr['address']['geocode']['address'];
    			if( $geocode = $this->getGeoData( $gaddress ) ){
    				$fields = [
    					'formatted_address' 	=> $geocode['formatted_address'],
    					'country' 				=> $geocode['country'],
    					'country_code' 			=> $geocode['country_code'],
    				];
    				$company = get_field('company');
    				foreach ($fields as $key => $value) {
    					update_post_meta( $post_id , $field . $key, $value );
    				}
    
    			}
    		}
    	}
    }
  • With the second approach i get true
    var_dump(update_sub_field( 'formatted_address', $geocode['formatted_address'] ));
    But nothing is saved

  • I’m trying another approach but without luck…

    if( have_rows( 'company', $post_id ) ):
    	while( have_rows('company', $post_id ) ) : the_row(); //group field
    		if( have_rows('addresses') ):
    			while( have_rows('addresses') ) : the_row(); //repeater field
    				if( have_rows('address') ):
    					while( have_rows('address') ) : the_row(); //group field
    						update_sub_field( 'formatted_address',  $geocode['formatted_address'] );
    					endwhile;
    				endif;
    			endwhile;
    		endif;
    	endwhile;
    endif;

    Any idea ?
    Thanks

  • The problem was caused by this
    File structure
    | +- PluginName
    | +- admin
    | +- admin.php
    | +- lib
    | +- advanced-custom-fields-pro/acf.php
    | +- acf.php
    | +- PluginName.php
    so on the PluginName.php I required admin.php and admin.php was requesting acf.php if the class acf doesn’t exist… nothing very fancy and acf was working but all the admin ajax actions made by acf where throwing error 400.

    So the solution was very easy; Just request (include) acf.php on the file PluginName.php instead of including acf on admin.php

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