This repository was archived by the owner on Dec 29, 2021. It is now read-only.
generated from spatie/package-skeleton-laravel
-
-
Notifications
You must be signed in to change notification settings - Fork 4
Form ToggleField
Luca Longo edited this page Aug 26, 2020
·
2 revisions
Render a toggle field that allows binary values (true/false). It's like a checkbox, but empowered!
| name | type | default value | description |
|---|---|---|---|
| id | ?string | null | Field ID (autogenerated if empty) |
| name | ?string | null | Field name |
| label | ?string | null | Label visible on the form |
| errorBag | ?string | null | Error field returned from the bag |
| disabled | bool | false | Determs if the field is disable (or not) |
| readOnly | bool | false | Determs if the field is read-only (or not) |
| value | mixed | null | Field value |
| trueValue | mixed | true | Value that match the true condition |
| falseValue | mixed | false | Value that match the false condition |
<x-bc-form:toggle-field label="Toggle field" error-bag="toggleField" :value-format="true" @input="console.log('Value changed')" />or, if you use Laravel Livewire:
<x-bc-form:toggle-field label="Toggle field" error-bag="toggleField" :value-format="true" wire:model="toggleField" />You can also customize the values:
<x-bc-form:toggle-field label="Toggle field" error-bag="toggleField" :value-format="yes" wire:model="toggleField" true-value="yes" false-value="no" />prependappend
Example:
<x-bc-form:toggle-field>
<x-slot name="prepend">Prepend</x-slot>
<x-slot name="append">Append</x-slot>
</x-bc-form:toggle-field>