-
-
Notifications
You must be signed in to change notification settings - Fork 42
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
Checkbox/toggle control values not returned correctly in get_lzb_meta #185
Comments
Hey. If I understand correctly, post meta is not saved properly? Maybe these issues related to yours?
Please, check it and let me know helped it or not |
Afraid not - the data is saved correctly in the database, but the E.g. with the fix I added above, I got the correct data without having to re-save anything to the database. |
This is strange because when I tested it, meta returned correctly for controls with default checked value and without default. Anyway, this code part (https://github.com/nk-o/lazy-blocks/blob/master/src/controls/toggle/index.php#L87-L108) will be removed in the coming plugin update and your issue should be resolved. This code part was as a workaround for default meta values. Since WordPress 5.5 we can define a default value for meta using official API and our hack no more needed. |
Ah got it - thanks for the help, I'll leave my fix in for now until the update. |
Issue description:
This is my first time using Lazy Blocks (and it's been a while since I've worked with Wordpress), so apologies if I've missed something obvious here, but I'm getting a bit of an odd issue when I try to use checkboxes/toggles and include their value in a template I'm building - I can't get
get_lzb_meta
to return the correct checked/unchecked value of a toggle or checkbox. Instead, it seems to return the value of the set up option (should the control be checked/toggled by default).Lazy Blocks Version:
2.3.0
WordPress Version:
5.6
Any helpful information to reproduce the issue (screenshots, code parts)
To reproduce:
I create a new field "show-down-arrow" as a toggle. I make sure I've checked to include this in Meta. I then use the block on a page, and set the value to checked/toggled.
When I try to inspect the value in PHP in a template file, e.g.
I always get the value of $control['checked'] returned, which seems to just be what the default value of the control should be.
I tried to do some debugging, and it looks like the
filter_get_lzb_meta_default
function incontrols/toggle/index.php
is returning the wrong result, specifically:As far as I can tell, this should be checking whether
$result
is either blank (unchecked) or'1'
(checked). Checking the$control['checked']
seems like it's just checking whether the toggle should be "toggled" by default:I'm happy to have a go at writing a PR if this looks like a bug from your end as well. Thanks
The text was updated successfully, but these errors were encountered: