Home › Forums › Bug Reports › Radio Buttons don't retain choices on export/import
I’ve just noticed that when exporting a field group VIA the Custom Fields > Tools > Download export file function, then importing them to another site the Choices values for Radio buttons are not being retained.
Haven’t checked other fields that have Choices.
The import process often hangs as well, haven’t bothered to debug this but perhaps it’s to do with this.
I did some testing and it appears that this has been fixed on the dev version of ACF and should be included in the next update.
No I don’t, but if you want to fix it sooner
in advanced-custom-fields-pro/api/api-helpers.php
Look for the function acf_decode_choices and replace it with the following code.
function acf_decode_choices( $string = '' ) {
// bail early if already array
if( is_array($string) ) {
return $string;
// allow numeric values (same as string)
} elseif( is_numeric($string) ) {
// do nothing
// bail early if not a string
} elseif( !is_string($string) ) {
return array();
// bail early if is empty string
} elseif( $string === '' ) {
return array();
}
// vars
$array = array();
// explode
$lines = explode("\n", $string);
// key => value
foreach( $lines as $line ) {
// vars
$k = trim($line);
$v = trim($line);
// look for ' : '
if( acf_str_exists(' : ', $line) ) {
$line = explode(' : ', $line);
$k = trim($line[0]);
$v = trim($line[1]);
}
// append
$array[ $k ] = $v;
}
// return
return $array;
}
This is also a problem if you “Move” a field to another ACF group. The choices empty out.
It looks like there’s another issue relating to this, with true/false fields. Only on import it appears to wipe out the fields in that group. Very peculiar.
Try syncing the attached file. You should have three fields, but only one, and it’s almost empty.
Can you try the latest update for ACF pro and see if the problem with imports has been corrected?
I’m using ACF pro 5.3.6.1 and ‘Choices’ for Radio Buttons aren’t being saved in the json export files.
Where do I get the latest ‘dev’ version please?
Actually, I’ve found that the problem is when I’ve updated from ACF to ACF Pro then clicked the ‘update database’ button the Choices are being lost?
@zigzagad if you haven’t already done so you should probably open a new support ticket http://support.advancedcustomfields.com/new-ticket/.
The topic ‘Radio Buttons don't retain choices on export/import’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.