Basics
Contains all basic methods.
The Checkbox field is a field for selecting a yes/no value.
Creation
use MoonShine\UI\Fields\Checkbox;Checkbox::make('Publish', 'is_publish')use MoonShine\UI\Fields\Checkbox;Checkbox::make('Publish', 'is_publish')
<x-moonshine::form.wrapper label="Publish"><x-moonshine::form.inputtype="checkbox"name="is_publish"/></x-moonshine::field-container><x-moonshine::form.wrapper label="Publish"><x-moonshine::form.inputtype="checkbox"name="is_publish"/></x-moonshine::field-container>
On/Off Values
By default, the field has values 1 and 0 for selected and unselected states respectively.
The onValue() and offValue() methods allow you to override these values.
onValue(int|string $onValue)onValue(int|string $onValue)
offValue(int|string $offValue)offValue(int|string $offValue)
Checkbox::make('Publish', 'is_publish')->onValue('yes')->offValue('no')Checkbox::make('Publish', 'is_publish')->onValue('yes')->offValue('no')
Preview Editing
This field supports preview editing.