• Resolved WPSeeker

    (@wpseeker)


    Hi

    Thanks for this very useful plugin.

    I have created a single checkbox and want the value being set to be ‘yes’, but it seems to only output ‘on’ no matter what I try.

    Is there a way to change the value recorded when this is checked?

    https://wordpress.org/plugins/cmb2/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Not sure about just the standard checkbox field type, but multicheck works for custom value attributes, and you don’t need to set many.

    Justin may have a better idea.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Ever find a working solution to this WPSeeker?

    In case anyone else comes across this, I was able to accomplish this with the following field definition:

    array (
      'id' => '_featured',
      'name' => 'Featured?',
      'desc' => 'Check to feature this item on the home page.',
      'type' => 'checkbox',
      'attributes' => array (
        'value' => '1',
      )
    )

    Actually, sorry, that makes the checkbox input tag have value=”1″ but it won’t save to the database. So, never mind.

    • This reply was modified 7 years, 6 months ago by jazbek.
    • This reply was modified 7 years, 6 months ago by jazbek.
    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    I believe CMB2 uses “on” for a checkbox value that should be toggled, if I’m not mistaken.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Changing checkbox value’ is closed to new replies.