Skip to content

Toggle

A switch for yes / no.

use Anvil\Schema\Fields\Toggle;
Toggle::make('newsletter')->label('Receives newsletter'),
Toggle::make('is_active')->label('Active')->default(true),

The options of every field. The default is false; required() has no effect (a switch always has a value). The label is shown next to the switch.

1 or 0 (use a TINYINT(1) column). Browsers do not submit unchecked checkboxes, so the form always sends a hidden 0 first: switching off is saved.

permit_empty, in_list[0,1], then the rules of rules().

“Yes” with a green check or “No”.

A boolean. Requests may send true/false, 1/0 or "1"/"0"; null is false, anything else fails the validation.