Advanced Custom Fields
Multiple checkbox values not selected (1 post)

  1. Michael Cannon
    Posted 4 years ago #

    $field['value'] for core/fields/checkbox.php in function create_field isn't an array itself, but a CSV. As such, the in_array() call to set selected will never work. The fix is to convert the CSV to an array like below.

    function create_field($field)
            // defaults
            if(empty($field['value'])) {
                $field['value'] = array();
            } else {
                $field['value'] = explode(',', $field['value']);

    Also, the correct way to check a checkbox is $selected = 'checked="checked"'; not $selected = 'checked="yes"';.

    Great extension, especially now that I have the ability to pull in configurations via PHP code dynamically based upon my arbitrary conditions.


Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Advanced Custom Fields
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

  • RSS feed for this topic
  • Started 4 years ago by Michael Cannon
  • This topic is not resolved
  • WordPress version: 3.3.1