Data Structure
Flicking the toggle to the right sets to the value to true
, left to false
.
do_the_thing: true
Templating
Toggles are usually used to control logic, so you can combine them with {{ if }}
statements in your templates to handle all manner of show/hide wizardry.
{{ if do_the_thing }} It does it {{ /if }}
The following example uses the fetch
helper function, which resolves Value
instances for you and returns the underlying value. This way you always get the real "truthy" value, regardless of how you retrieved $do_the_thing
.
<?php use function Statamic\View\Blade\{fetch};?> @if (fetch($do_the_thing)) It does it@endif