Support

Account

Forum Replies Created

  • Hello,

    i clean the code

    		
    if( is_array($value) ) {
    
    	foreach ($value as $key => $val) {
    
    		//echo var_dump($val);
    		if ( isset($val['value']) ) {
    			$value[$key] = $val['value']; // when value is available, like return value/label with API in json
    		} else {
    			$value = array_map('strval', $value); // will get directly the parent array
    		}
    
    	}
    
    }
    


    @team
    , do you need more informations for apply this fix to ACF ?

    Thanks

  • Ok i find the issue,

    for valid the update field, we must return only the value (get_field without format), like :

    	$arr = array(
    			  "0" => "test1",
    			  "1" => "test2"
    		  );

    Then the core ACF will save the field correctly with value.

    But, i use the get_fields() in my API, then the developper of APP from my WordPress, return all fields with value/label, so i must modified the core of ACF.

    like :
    includes\fields\class-acf-field-select.php – line 526

    		
    if( is_array($value) ) {
        //$value = array_map('strval', $value); // OLD // remove array and up the value in parent array
    
        // will print the array and select only the value
        foreach ($value as $key => $val) {
            // check if have more 2 characters, some field return 1 letter :/
            if ( strlen($val['value']) > 2 ) {
    		$value[$key] = $val['value'];
    	} else {
    		$value = array_map('strval', $value);
    	}
        }
    }
    

    That quick code is used for select field and checkbox field.

    Can you add some filter for help developper ?

    thanks,
    Best Regards, Mat.

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