Hi @docdunning,
Thanks for letting me know about that.
That should have been fixed in this PR, but it’s not released on wp.org yet:
https://github.com/studiopress/genesis-custom-blocks/pull/60
I’m not sure when we’ll release it.
Could you do me a huge favor and see if this .zip of the plugin fixes it?
https://github.com/studiopress/genesis-custom-blocks/pull/60#issuecomment-802247810
Thanks, Martin!
Though that won’t do exactly what you mentioned. It makes the default of the Toggle and Checkbox fields false, like in the previous editor from 1.0.3.
@ryankienstra
Hi Ryan – I think that has done the trick. I see what you mean, that when creating the block, the default is now “false”, but that’s not the issue that I had.
My issue was when using the block. Although the default was “true”, and the UI was showing the Toggle / Checkbox controls as checked, they were passing “false” to the block.php handler.
I did have to delete and recreate the block with the updated plugin before it worked as expected, but that’s no big deal in my case.
Happy to do some more checks/diagnostics if that would help.
Martin
Hi @docdunning,
Ah, OK. I should have mentioned that recreating the field or block would be needed.
I did have to delete and recreate the block with the updated plugin before it worked as expected, but that’s no big deal in my case.
After recreating the block, did block_field() or block_value() have the correct result?
For example, here are the steps I took:
1. Create a new GCB block
2. Add a new Checkbox field, leaving the default as unchecked: https://cldup.com/lN_AwV5TwQ.png
3. Go to Gutenberg
4. Add that block: https://cldup.com/K_uxa0TQf0.gif
5. Click away from it so the template displays
6. Expected: block_field( 'your-field-name' ) echoes 'No'
Hi @ryankienstra
All good, as far as I can see. I set up a block with two Checkboxes and two Toggles, with one of each defaulting “True” and the other “False”.
My block.php code runs like this:
<?php
echo 'Check false: ',block_field( 'check-false' ),'<br>';
echo 'Check true: ',block_field( 'check-true' ),'<br>';
echo 'Toggle false: ',block_field( 'toggle-false' ),'<br>';
echo 'Toggle true: ',block_field( 'toggle-true' ),'<br>';
echo 'Check false: ';var_dump(block_value( 'check-false' )); echo '<br>';
echo 'Check true: ';var_dump(block_value( 'check-true' )); echo '<br>';
echo 'Toggle false: ';var_dump(block_value( 'toggle-false' )); echo '<br>';
echo 'Toggle true: ';var_dump(block_value( 'toggle-true' )); echo '<br>';
I add the block to a page and click away, and see this (as expected):
Check false: No
Check true: Yes
Toggle false: No
Toggle true: Yes
Check false: bool(false)
Check true: bool(true)
Toggle false: bool(false)
Toggle true: bool(true)
I won’t use this pre-release version on the live site as yet though.
Hi @docdunning,
Great, thanks a lot for testing it and sharing the code.
Right, that .zip file isn’t production-ready, unfortunately. I’m not sure when it’ll be released, but I’ll ping you here if you’d like.
Hi @docdunning,
Sorry for the long delay. This issue should be fixed in yesterday’s 1.2.0 release.