Support

Account

Home Forums General Issues Select options not working when the choice string include comma Reply To: Select options not working when the choice string include comma

  • The value is saved properly into the database, and will be reflected on the front-end correctly, but on the admin side the value won’t be reflected. This is troubling because if you save again, you will overwrite the field if you don’t remember to update it.

    This seems to be happening because the value for select fields is run through the acf_force_type_array() function. That function has this troublesome code:

    
    if( is_string($var) ) {	
        return explode(',', $var);
    }
    

    Basically when you are on the admin side, it splits your Doe, John value into two values, Doe and John. Since that doesn’t match any of the values in the HTML, the select is left on the default first option.

    I tried replacing the commas with , which is the HTML Entity for a comma, but it causes a different issue, that value is reflected as , instead, and so you end up with the same non-matching issue as before.

    I don’t have a fix for this, but thought I’d shed some light on what’s happening. Hopefully Elliot can chime in and take a look at a fix for this.