mahmudkuet11 / nova-multiselect-field
A multiple select field for Laravel Nova.
1.5.0
2019-08-13 18:20 UTC
Requires
- php: >=7.1.0
README
This Laravel Nova package adds a multiselect to Nova's arsenal of fields.
Screenshots
Installation
Install the package in a Laravel Nova project via Composer:
composer require mahmudkuet11/nova-multiselect-field
Usage
The field is used similarly to Nova's native Select field. The field type in the database should be text-based (ie string
, text
or varchar
), selected values are stored as a JSON array.
use Mahmud\MultiselectField\Multiselect; public function fields(Request $request) { return [ Multiselect ::make('Favourite football teams', 'football_teams') ->options([ 'liverpool' => 'Liverpool FC', 'tottenham' => 'Tottenham Hotspur', 'bvb' => 'Borussia Dortmund', 'bayern' => 'FC Bayern Munich', 'barcelona' => 'FC Barcelona', 'juventus' => 'Juventus FC', 'psg' => 'Paris Saint-Germain FC', ]) // Optional: ->placeholder('Choose football teams') ->max(4) ->optionsLimit(5) ]; }
Options
Possible options you can pass to the field using the option name as a function, ie ->placeholder('Choose peanuts')
.
Credits
License
This project is open-sourced software licensed under the MIT license.