-
Notifications
You must be signed in to change notification settings - Fork 89
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
What is the expected behaviour for std values in checkboxes #102
Comments
👍 |
I believe I am seeing the same issue: If for an individual checkbox item the default ( To reproduce: $meta->addCheckbox( $prefix . 'design_show_banner', array( 'name' => __( 'Show banner', BACKEND_TEXTDOMAIN ), 'std' => true, 'class' => 'no-fancy') ) ); |
It works for the reversed logic meaning instead of "un-check to disable feature x" you use "check to enable feature x" |
"Check to enable feature X" is exactly what my example above does - it displays a banner if that checkbox is checked. It would work just fine if it were not checked by default, which I would like to be the case. Once you let this default to 'checked', the checkbox can no longer be unchecked... so if I want the feature enabled by default, it does not work as expected. Thanks for looking into this - and Happy New Year! |
Once again its working for reversed login, which means in your case it should be "check to disable" but as I said, I'll see what i can do. |
Thank you. I very much appreciate that. |
Hi there, I've noticed the same behavior, was wondering if a workaround has been introduced somewhere. Thanks again for the amazing work! I'm integrating a project that uses 'open (checked)/closed (unchecked)' for the checkbox values, and I realized setting 'std' defaults always leaves boxes checked. If the box is unchecked, the meta_key is dropped, which would be fine unless your code is looking for that 'closed'(unchecked) value. I'm assuming it's just a question of adding conditionals into the save() function of my-meta-box-class.php...did anyone create a workaround for this? |
First of all, great class ! Thank you ! In my-meta-box-class.php, I changed the following lines (put one line in comment and add a couple more) : public function show() {
... So, for a checkbox, I verify if the post status is "auto draft" (meaning we are adding a new post) before using the default (std) value. Seems to work good... Hope It will help... |
First of all, thank you for this class. It is exactly what I was searching for and exactly the way I would like to work with.
I found this question using/studying it:
If I set a
std
value for acheckbox
orcheckboxlist
as "checked", is there a way to uncheck and override this value?I mean, it was suposed to this
std
be an unchangeable value or just a initial value for fields?If is an unchangeable value, it could be disabled so user won't get frustrated unchecking and getting the field checked again on page reload.
Else if is just an initial value, could be nice to override this default value with saved one.
The text was updated successfully, but these errors were encountered: