mohkoma/nova-multiselect-checkboxes

A Laravel Nova Multiselect Dropdown Field.

v0.1 2020-02-19 06:32 UTC

This package is auto-updated.

Last update: 2024-05-28 17:28:33 UTC


README

Checkboxes in Laravel Nova

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