Title: Multicheck boxes default behavior
Last modified: February 9, 2018

---

# Multicheck boxes default behavior

 *  Resolved [Stuart Shields](https://wordpress.org/support/users/sbshields9/)
 * (@sbshields9)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/multicheck-boxes-default-behavour/)
 * Hi,
 * I was wondering if you could please verify the default behavior of how multicheck
   boxes work.
 * Do you need at-least one checkbox checked?
 * So currently, I have 1 checkbox, if I check it, it saves as it should.
 * However as soon as I uncheck it, on save the box remains checked.
 * The database reflects no change was made (so it stores the value of the checkbox).
 * This happens in both Firefox and Chrome, I’m wondering if this is the expected
   behavior and if so, is there a way around it?
    -  This topic was modified 8 years, 4 months ago by [Stuart Shields](https://wordpress.org/support/users/sbshields9/).

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Plugin Contributor [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [8 years, 4 months ago](https://wordpress.org/support/topic/multicheck-boxes-default-behavour/#post-9957344)
 * You should be able to deselect everything, save, and have things remaining deselected.
 * I just tried with the example found at [https://github.com/CMB2/CMB2/wiki/Field-Types#multicheck-and-multicheck_inline](https://github.com/CMB2/CMB2/wiki/Field-Types#multicheck-and-multicheck_inline)
   and it worked for me.
 * Can you provide the CMB2 config you’re using for your example?
 *  Thread Starter [Stuart Shields](https://wordpress.org/support/users/sbshields9/)
 * (@sbshields9)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/multicheck-boxes-default-behavour/#post-9963320)
 * Here is how we are calling the multicheck if you need more let me know. Also 
   this is running on an options page if that helps.
 *     ```
        [
       	[
       		'name'    => __( 'Active feeds', 'asd-feeds' ),
       		'desc'    => __( 'Activate / Deactivate feeds', 'asd-feeds' ),
       		'id'      => 'active_feeds',
       		'type'    => 'multicheck',
       		'options' => array_column( $this->feeds, 'title', 'id' ),
       	],
       	[
       		'name' => __( 'Debug mode', 'asd-feeds' ),
       		'desc' => __( 'Enable debug mode, ie: more verbose logging.', 'asd-feeds' ),
       		'id'   => 'debug',
       		'type' => 'checkbox',
       	],
       ];
       ```
   
    -  This reply was modified 8 years, 3 months ago by [Stuart Shields](https://wordpress.org/support/users/sbshields9/).
    -  This reply was modified 8 years, 3 months ago by [Stuart Shields](https://wordpress.org/support/users/sbshields9/).
 *  Plugin Contributor [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [8 years, 3 months ago](https://wordpress.org/support/topic/multicheck-boxes-default-behavour/#post-9963427)
 * Can you provide a static version of what is found in the feeds property for your
   usage? the part from `$this->feeds`
 *  Thread Starter [Stuart Shields](https://wordpress.org/support/users/sbshields9/)
 * (@sbshields9)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/multicheck-boxes-default-behavour/#post-9971668)
 * Do you have an email address that I can share a gist with? I’d rather not show
   code from a client.
 *  Plugin Contributor [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [8 years, 3 months ago](https://wordpress.org/support/topic/multicheck-boxes-default-behavour/#post-9971711)
 * `michael@webdevstudios.com` will reach me
 *  Plugin Contributor [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [8 years, 3 months ago](https://wordpress.org/support/topic/multicheck-boxes-default-behavour/#post-9972352)
 * confirming i did receive the email and have the php class provided. Took a few
   to figure out how to get a similar setup, set up. I replaced the `$this->feeds`
   with a generic array of key/value pairs.
 * Definitely able to recreate this one, and looking over the GitHub issues list,
   we had a similar case this past summer, that is still unresolved.
 * [https://github.com/CMB2/CMB2/issues/978](https://github.com/CMB2/CMB2/issues/978)
 * Three options I can see at the moment.
 * 1. This is a new one that I didn’t think of when I filed the issue. Have the 
   multi-check option be the last time in the page. It seems to clear appropriately
   in that situation.
 * 2. First from the GitHub issue above. I was able to get around it by setting 
   a value in the 2nd one, and then unchecking the first ones, and that seemed to
   work. Then, on a 2nd save of the page, uncheck the second item and then all of
   them were empty finally. This was able to be done without the hidden field that
   you set.
 * 3. Second from the GitHub issue above. An alternate idea that may help would 
   just be to have a “none” option that you don’t actually do anything with on the
   frontend or wherever you’re using these values at.
 * Not sure exactly what the project specs are and how flexible you’ll be able to
   be here. Given the wonky nature of 2 of the ideas, I’d probably personally settle
   on idea 3 with the “none” option as a default.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Multicheck boxes default behavior’ is closed to new replies.

 * ![](https://ps.w.org/cmb2/assets/icon.svg?rev=2866672)
 * [CMB2](https://wordpress.org/plugins/cmb2/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/cmb2/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/cmb2/)
 * [Active Topics](https://wordpress.org/support/plugin/cmb2/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/cmb2/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/cmb2/reviews/)

 * 6 replies
 * 2 participants
 * Last reply from: [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * Last activity: [8 years, 3 months ago](https://wordpress.org/support/topic/multicheck-boxes-default-behavour/#post-9972352)
 * Status: resolved