We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 05601e4 commit 1f11c9cCopy full SHA for 1f11c9c
src/Fieldtypes/Toggle.php
@@ -17,4 +17,9 @@ public function process($data)
17
{
18
return (bool) $data;
19
}
20
+
21
+ public function augment($data)
22
+ {
23
+ return (bool) $data;
24
+ }
25
tests/Fieldtypes/ToggleTest.php
@@ -0,0 +1,20 @@
1
+<?php
2
3
+namespace Tests\Fieldtypes;
4
5
+use Statamic\Fields\Field;
6
+use Statamic\Fieldtypes\Toggle;
7
+use Tests\TestCase;
8
9
+class ToggleTest extends TestCase
10
+{
11
+ /** @test */
12
+ public function it_augments_to_a_boolean()
13
14
+ $field = (new Toggle)->setField(new Field('test', ['type' => 'toggle']));
15
16
+ $this->assertFalse($field->augment(false));
+ $this->assertFalse($field->augment(null));
+ $this->assertTrue($field->augment(true));
+}
0 commit comments