mohkoma / nova-multiselect-checkboxes
A Laravel Nova Multiselect Dropdown Field.
Requires
- php: >=7.1.0
This package is auto-updated.
Last update: 2024-08-28 18:14:21 UTC
README
Installation
composer require mohkoma/nova-multiselect-checkboxes
Usage
use Nova\MultiselectCheckboxes\MultiselectCheckboxes; MultiselectCheckboxes::make('Options', 'FIELD_NAME') ->options($this->{FIELD_NAME}->pluck('name', 'id')) ->placeholder('Options'),
Configuration
Use the options()
function to pass the options list, the function accept the options as first parameter (it must be an keyed array $this->{FIELD_NAME}->pluck('name', 'id')
) and optionally the selections as a secound parameters (must be an array of ids).
Please note that if you don't pass the selections, the package will use the field default value ex: FIELD_NAME
column in the exemple above.
use Nova\MultiselectCheckboxes\MultiselectCheckboxes; ->options($this->{FIELD_NAME}->pluck('name', 'id'), [23, 34, 66, 76])
You're able to set a placeholder for the field using placeholder()
function.
Sometimes you might need to return the value of the unselected options, for that you can use returnUnchecked()
function.
use Nova\MultiselectCheckboxes\MultiselectCheckboxes; MultiselectCheckboxes::make('Options', 'FIELD_NAME') ->options($this->{FIELD_NAME}->pluck('name', 'id')) ->placeholder('Options') ->returnUnchecked(),
License
MIT