Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Single Checkbox Won't Uncheck #34

Open
INVSBL-HND opened this issue Feb 13, 2013 · 1 comment
Open

Single Checkbox Won't Uncheck #34

INVSBL-HND opened this issue Feb 13, 2013 · 1 comment

Comments

@INVSBL-HND
Copy link

Single checkbox meta fields won't "uncheck" and simply revert to the "checked" state upon saving the post.

I've rewritten the checkbox case to conditionally create a hidden input type with the same name as the checkbox input to allow for successful checking, unchecking, and rechecking of single checkboxes.

Below is my suggestion for replacing lines 62-66 of meta_box.php

// checkbox
case 'checkbox': 
echo '<input type="checkbox" name="' . esc_attr( $name ) . '" id="' . esc_attr( $id ) . '" ' . ($meta ? 'checked="checked"/><input type="hidden" name="' . esc_attr( $id ) . '"' : '').'/
<label for="' . esc_attr( $id ) . '">' . $desc . '</label>';
break;

Screen Shot 2013-02-13 at 11 40 27 AM

@LinzardMac
Copy link

I'e tried this method of fixing the error but it does not seem to work. I adjusted your variables to match my own and the HTML output is as expected but I stil get the undefined index and "headers already sent" errors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants