-
-
Notifications
You must be signed in to change notification settings - Fork 86
Multiselect
tanthammar edited this page Apr 8, 2021
·
7 revisions
- Tall-forms minimum: v5.2.2
See Select field for additional methods
- This field uses the Select field and all methods are the same.
- The field value is an array
Define the field as custom()
to manipulate the field value and manually save the data.
See Custom data page
More examples can be found on the Relations wiki page.
public function saveFoo($validated_value)
{
// the multiselect returns an array
dd($validated_value);
}
public function select()
{
$options = ['Wifi' => 'wf', 'Bluetooth' => 'bl', 'Ethernet' => 'eth'];
return MultiSelect::make('Select')
->options($options) //see Select or Relations wiki page on how to define options
->custom() //optional: save the data with saveFoo() event hook, see custom data page
->default(['wf'])
->fieldWidth('w-full sm:max-w-sm')
->wire('wire:model.defer')// if you don't want a network request on every click in the select
->placeholder('Please select one or multiple options')
->rules(['nullable', Rule::in(collect($options)->values()->implode(','))]);
}
<x-tall-select :field="$field" />
Extend Blade component (or override in config file)
Tanthammar\TallForms\Components\Select::class
//Select placeholders and help, applied as trans(...) or @lang(...)
'multiselect-placeholder' => 'global.multiselect_placeholder', //'Please select one or multiple options ...'
'multiselect-help' => 'global.multiselect_help', //'Press CTRL(Windows) or CMD(Mac), to select/deselect multiple options.'
- Installation
- Requirements
- v5 Upgrade Guide
- v6 Upgrade Guide
- v7 Upgrade Guide
- Support
- Quickstart
- Manual installation
- Optional
- Form component
- Field
- Field types
- Example Form
- Blade Components
- Notifications