Hi there,
I recently wanted to use the 'Switch' element in a custom post type as documented here: https://docs.metabox.io/fields/switch/.
I added a switch element to my array of custom fields like this:
[
'id' => 'enable_switch',
'name' => 'Enable This',
'type' => 'switch',
'style' => 'square',
'on_label' => 'Enabled',
'off_label' => 'Disabled',
'std' => true,
],
However, the 'std' => true,
attribute is never respected to default the switch to an "on" status. This attribute is what is used by your Metabox builder as the "ON by Default" PHP output.
I have also tried a range of other permutations such as 'std' => 1,
OR 'std' => 'Enabled',
but none of these seem to work either?
Is this a bug? Or am I unaware of the correct method to default the switch to an "on" status?
I look forward to your response.