Open niallkennedy opened 9 years ago
Thanks again for the report, @niallkennedy. We'll get this fixed for the next release.
Holding on this change for v0.5.0, as I don't yet feel 100% confident about this change.
This was a recurring issue with Visual Composer a while back.
There are three states:
Shortcake needs to support all three of these in order for the checkbox to work in a meaningful way.
Yes this makes checkboxes useless in some cases where we need to check for a false
value. It's easy to work around with a select field and defining true
and false
keys but checkboxes are better suited for boolean values.
A shortcode includes a boolean attribute, do_the_thing, with a default state of true. A falsey attribute value overrides the default.
The shortcode author exposes the attribute to Shortcake through a
checkbox
field type, passing avalue
oftrue
in string form, resulting in a checked property output intmpl-shortcode-ui-field-checkbox
. The default value of the shortcode is communicated.The viewer unchecks the checkbox, overriding the default.
If Shortcake built an attribute value of
false
for the unchecked checkbox state the author's shortcode handler could respond to falsey values as well as truthy values for the generated shortcode.The existing template behavior requires a string of
true
to set the truthy state. A shortcode could be similarly expected to respond to a string offalse
generated by Shortcake to represent the falsey state.Example shortcode result
Example registered shortcode fragment