Support

Account

Home Forums Bug Reports Update field for multiple choose with array Reply To: Update field for multiple choose with array

  • 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.