Field reference

Toggle field

A true/false switch for feature flags and display decisions.

#Field definition

Add this array inside a block, field group, or option page fields list.

PHP
['field_key' => 'show_cta', 'label' => 'Show call to action', 'type' => 'toggle', 'default_value' => true]

#Saved value

PropertyValue
Field typetoggle
PHP / REST valueboolean
Empty value"" or the configured default

#Rendering example

Read block fields from $attributes. Post fields use voxycure_get_field(); option fields use voxycure_get_option().

PHP
if (!empty($attributes['show_cta'])) {
    echo '<a class="button" href="/contact/">Contact us</a>';
}

#Common field options

KeyTypePurpose
field_keystringRequired unique storage key using lowercase letters, numbers, underscores, or hyphens.
labelstringHuman-readable editor label.
default_valuemixedValue used before content is saved. Match the field value type.
requiredbooleanRejects an empty option-page submission.
conditional_logicarrayControls editor visibility based on another field.
locationstringdefault or inspector for block fields.
Framework version2.0.0
PHP requirement8.0+
Documentation updatedAugust 2026