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),Options
Section titled “Options”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.
Saved value
Section titled “Saved value”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.
Validation
Section titled “Validation”permit_empty, in_list[0,1], then the rules of rules().
Read-only
Section titled “Read-only”“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.