PHPackages                             dvarilek/filament-table-select - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. dvarilek/filament-table-select

ActiveLibrary

dvarilek/filament-table-select
==============================

Laravel Filament form component for selecting related records with a table.

v2.0.7(9mo ago)397.6k↓44.4%7[1 issues](https://github.com/dvarilek/filament-table-select/issues)MITPHPPHP ^8.2|^8.3|^8.4CI passing

Since May 18Pushed 9mo ago2 watchersCompare

[ Source](https://github.com/dvarilek/filament-table-select)[ Packagist](https://packagist.org/packages/dvarilek/filament-table-select)[ RSS](/packages/dvarilek-filament-table-select/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (10)Versions (12)Used By (0)

Filament Table Select
=====================

[](#filament-table-select)

[![Latest Version on Packagist](https://camo.githubusercontent.com/f3c190914803b60b3abb8f4e0873ae7d289e58c6c5e5a7e4edf132319542fe20/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f64766172696c656b2f66696c616d656e742d7461626c652d73656c6563742e7376673f696e636c7564655f70726572656c6561736573)](https://packagist.org/packages/dvarilek/filament-table-select)[![Software License](https://camo.githubusercontent.com/074b89bca64d3edc93a1db6c7e3b1636b874540ba91d66367c0e5e354c56d0ea/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e737667)](LICENSE.md)[![Total Downloads](https://camo.githubusercontent.com/0547ca231f66361bc4b07a3ae23025c0738306171b9c88bb92dca8bde669da70/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f64766172696c656b2f66696c616d656e742d7461626c652d73656c6563742e737667)](https://packagist.org/packages/dvarilek/filament-table-select)

 [![Filament Table Select Banner](https://private-user-images.githubusercontent.com/93047221/443855344-80bf584a-a7bc-4586-98aa-27c377e2b6d3.png?jwt=eyJ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UzUFFLNFpBJTJGMjAyNjAzMjQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjYwMzI0VDE2NDIxM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTM0ZTM1NzA0YTExNjE1YzQ1MDRkMjJjOWUxOGQ3MGI1ZmZjMDVmZWYzMGJlMTVhMTNmOGFiOTNjNDU5ZjI3MWImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.oYzN3raRE7tKGI2BpbB8zrZtxb90_jY0736XXVImWL4)

---

Installation
------------

[](#installation)

```
composer require dvarilek/filament-table-select:^2.0.7
```

---

Overview
--------

[](#overview)

This package introduces a new Form component that acts as a replacement for the Select field by allowing users to select related records from a full-fledged Filament table through a relationship.

Naturally, using a table for selection provides much greater context and clarity, as users can interact with it like any other Filament table. The table can be fully customizable.

    filament-table-select-demo.mp4
Important

This package is only compatible with Filament v3.x. Starting with Filament v4.x, a new built-in component is available that offers a more polished and native implementation of similar functionality. See the [ModalTableSelect documentation](https://filamentphp.com/docs/4.x/forms/select#selecting-options-from-a-table-in-a-modal)

---

Getting Started
---------------

[](#getting-started)

Even though TableSelect doesn't extend the Select field directly, it borrows some functionality from it.

First, configure the relationship and title attribute using the `relationship()` method, which works the same way as in Filament's standard Select field. This method sets up a `BelongsTo` relationship to automatically retrieve options, where the `titleAttribute` specifies the column used to generate labels for each option.

```
use Dvarilek\FilamentTableSelect\Components\Form\TableSelect;

$form
    ->schema([
        TableSelect::make('clients')
            ->relationship('clients', 'name')
    ])
```

    single-select.mp4
### Multi Selection

[](#multi-selection)

The `multiple()` method enables to use a `belongsToMany()` relationship, which allows to select and associate multiple records.

```
use Dvarilek\FilamentTableSelect\Components\Form\TableSelect;

$form
    ->schema([
        TableSelect::make('clients')
            ->relationship('clients', 'name')
            ->multiple()
    ])
```

    multi-select.mp4
### Selected Items Validation

[](#selected-items-validation)

You can validate the minimum and maximum number of items that you can select in a multi-select by setting the `minItems()` and `maxItems()` methods:

```
use Dvarilek\FilamentTableSelect\Components\Form\TableSelect;

$form
    ->schema([
        TableSelect::make('clients')
            ->relationship('clients', 'name')
            ->multiple()
            ->minItems(1)
            ->maxItems(3)
    ])
```

Note

If `maxItems(1)` is set to 1, radio-like selection gets enabled regardless of the relationship type.

---

Customizing Selected Options
----------------------------

[](#customizing-selected-options)

### Label Configuration

[](#label-configuration)

The TableSelect field enables for customization of selected options and their badges.

To customize the color of selected options, use the `optionColor()` method:

```
use Dvarilek\FilamentTableSelect\Components\Form\TableSelect;

$form
    ->schema([
        TableSelect::make('clients')
            ->relationship('clients', 'name')
            ->multiple()
            ->optionColor('success')
    ])
```

 [![Filament Table Option Color Configuration](https://private-user-images.githubusercontent.com/93047221/451355905-1bd8f765-d502-4e13-842a-80a56b6d3b3f.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzQzNzA4MzMsIm5iZiI6MTc3NDM3MDUzMywicGF0aCI6Ii85MzA0NzIyMS80NTEzNTU5MDUtMWJkOGY3NjUtZDUwMi00ZTEzLTg0MmEtODBhNTZiNmQzYjNmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNjAzMjQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjYwMzI0VDE2NDIxM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWYxNTIzMjE5NWViMmJiOTVmMzNjODUxZjY3YjVlZmJjOTc3OWNhNTZmNmIwNDhjMzBkZDJjNDE5MzkyMzRmYTEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.WkfGueTkonX3nQ0AbzuAQethg6fUhgDTnladPnYdUBg)](https://private-user-images.githubusercontent.com/93047221/451355905-1bd8f765-d502-4e13-842a-80a56b6d3b3f.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzQzNzA4MzMsIm5iZiI6MTc3NDM3MDUzMywicGF0aCI6Ii85MzA0NzIyMS80NTEzNTU5MDUtMWJkOGY3NjUtZDUwMi00ZTEzLTg0MmEtODBhNTZiNmQzYjNmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNjAzMjQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjYwMzI0VDE2NDIxM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWYxNTIzMjE5NWViMmJiOTVmMzNjODUxZjY3YjVlZmJjOTc3OWNhNTZmNmIwNDhjMzBkZDJjNDE5MzkyMzRmYTEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.WkfGueTkonX3nQ0AbzuAQethg6fUhgDTnladPnYdUBg)
To customize the icon of selected options, use the `optionIcon()` method:

```
use Dvarilek\FilamentTableSelect\Components\Form\TableSelect;

$form
    ->schema([
        TableSelect::make('clients')
            ->relationship('clients', 'name')
            ->multiple()
            ->optionIcon('heroicon-o-bell')
    ])
```

[![Filament Table Select Option Icon Configuration](https://private-user-images.githubusercontent.com/93047221/451494108-43943a73-4de4-4ee8-89a2-db980e6cd081.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3Lm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ei1EYXRlPTIwMjYwMzI0VDE2NDIxM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTAxMDQ1YWY5NmJmZDRkMzA0YjcwMWVlMDc0NGRjMjkwY2MyOTEzNTc3YWJmYTVkYTY4YzY3YTE0MjE2NDUxMDMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.bWE7fqFX0VqTmHeIrsfHyYK-1YHfpswAB2p6YRoGRQI)
Even though both `optionColor()` and `optionIcon()` methods accept callbacks, they cannot work with the given record instance. This is done for performance reasons, so all selected options are not loaded into memory on each request.

To customize the colors of selected options while being able to access the Eloquent model instance, use the `getOptionColorFromRecordUsing()` method.

```
use Dvarilek\FilamentTableSelect\Components\Form\TableSelect;

$form
    ->schema([
        TableSelect::make('clients')
            ->relationship('clients', 'name')
            ->multiple()
            ->getOptionColorFromRecordUsing(function (Client $record) {
                return match ($record->status) {
                    'lead' => 'primary',
                    'closed' => 'success',
                    'lost' => 'gray',
                    'active' => 'danger',
                    default => 'primary'
                };
            })
    ])
```

 [![Filament Table Select Option Color Configuration 2](https://private-user-images.githubusercontent.com/93047221/451356043-4728ca95-eda6-496c-8d8d-de25fa538a89.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzQzNzA4MzMsIm5iZiI6MTc3NDM3MDUzMywicGF0aCI6Ii85MzA0NzIyMS80NTEzNTYwNDMtNDcyOGNhOTUtZWRhNi00OTZjLThkOGQtZGUyNWZhNTM4YTg5LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNjAzMjQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjYwMzI0VDE2NDIxM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTA0ZWZmNWI3YjFjMGQ2YTg5NDI1ZWI5ZGU2ODJkYTJkZGFiNGJlMmFhMjlmM2Q2NjNlOGY3ODU1ZTM3ZGQxZTEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.CmU2ZOC2w1B6rfnlm7B7VVVWP7GeaSsUJFoPxfvZZBw)](https://private-user-images.githubusercontent.com/93047221/451356043-4728ca95-eda6-496c-8d8d-de25fa538a89.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzQzNzA4MzMsIm5iZiI6MTc3NDM3MDUzMywicGF0aCI6Ii85MzA0NzIyMS80NTEzNTYwNDMtNDcyOGNhOTUtZWRhNi00OTZjLThkOGQtZGUyNWZhNTM4YTg5LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNjAzMjQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjYwMzI0VDE2NDIxM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTA0ZWZmNWI3YjFjMGQ2YTg5NDI1ZWI5ZGU2ODJkYTJkZGFiNGJlMmFhMjlmM2Q2NjNlOGY3ODU1ZTM3ZGQxZTEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.CmU2ZOC2w1B6rfnlm7B7VVVWP7GeaSsUJFoPxfvZZBw)
To customize the icons of selected options while being able to access the Eloquent model instance, use the `getOptionIconFromRecordUsing()` method.

```
use Dvarilek\FilamentTableSelect\Components\Form\TableSelect;

$form
    ->schema([
        TableSelect::make('clients')
            ->relationship('clients', 'name')
            ->multiple()
            ->getOptionIconFromRecordUsing(function (Client $record) {
                return match ($record->status) {
                    'lead' => 'heroicon-o-light-bulb',
                    'closed' => 'heroicon-o-check-circle',
                    'lost' => 'heroicon-o-x-circle',
                    'active' => 'heroicon-o-bolt',
                    default  => 'heroicon-o-question-mark-circle',
                };
            })
    ])
```

[![Filament Table Select Option Icon Configuration 2](https://private-user-images.githubusercontent.com/93047221/451356118-5d79ccd6-f198-44ec-b334-f3b13e75536c.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzQzNzA4MzMsIm5iZiI6MTc3NDM3MDUzMywicGF0aCI6Ii85MzA0NzIyMS80NTEzNTYxMTgtNWQ3OWNjZDYtZjE5OC00NGVjLWIzMzQtZjNiMTNlNzU1MzZjLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNjAzMjQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjYwMzI0VDE2NDIxM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTNkYzQyMmYzOWViOWM4MWVhMTgyMDQ3MzQ4OWRkNGMyMDZlMWRmOTkzZDQ4ZTJiNTJjZjA2M2M3YjY0MzU2NTkmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.lAwb-8y8PwKAKjRU7u_dUHqZz0gWaS41nebfY_UxrN0)](https://private-user-images.githubusercontent.com/93047221/451356118-5d79ccd6-f198-44ec-b334-f3b13e75536c.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzQzNzA4MzMsIm5iZiI6MTc3NDM3MDUzMywicGF0aCI6Ii85MzA0NzIyMS80NTEzNTYxMTgtNWQ3OWNjZDYtZjE5OC00NGVjLWIzMzQtZjNiMTNlNzU1MzZjLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNjAzMjQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjYwMzI0VDE2NDIxM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTNkYzQyMmYzOWViOWM4MWVhMTgyMDQ3MzQ4OWRkNGMyMDZlMWRmOTkzZDQ4ZTJiNTJjZjA2M2M3YjY0MzU2NTkmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.lAwb-8y8PwKAKjRU7u_dUHqZz0gWaS41nebfY_UxrN0)
To customize the labels of selected options while being able to access the Eloquent model instance, use the `getOptionLabelFromRecordUsing()` method.

```
use Dvarilek\FilamentTableSelect\Components\Form\TableSelect;

$form
    ->schema([
        TableSelect::make('clients')
            ->relationship('clients', 'name')
            ->multiple()
            ->getOptionLabelFromRecordUsing(function (Client $record) {
                 return "{$record->first_name} {$record->last_name} - {$record->status}";
            })
    ])
```

[![Filament Table Select Option Label Configuration](https://private-user-images.githubusercontent.com/93047221/451356152-e88e1abb-234b-4e27-ae18-8d6062775a9c.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzQzNzA4MzMsIm5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PWRkNjQwM2MwY2VlODMxYjQxYTBkMTU3NmJhZTVlMzllMTU4MDMxOTJiZThjYjhhODgyNjRkMDAyZmJmYmZhYzImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.8BHRoQXXDkGTl0RhfofMnV-82F6R6YX7EoV-66_uWXs)
### Other Configuration Options

[](#other-configuration-options)

To customize the size of selected option badges, use the `optionSize()` method:

```
use Dvarilek\FilamentTableSelect\Components\Form\TableSelect;
use Filament\Support\Enums\ActionSize;

$form
    ->schema([
        TableSelect::make('clients')
            ->relationship('clients', 'name')
            ->multiple()
            ->optionSize(ActionSize::Large)
    ])
```

To customize the size of selected option badges, use the `optionIconSize()` method:

```
use Dvarilek\FilamentTableSelect\Components\Form\TableSelect;
use Filament\Support\Enums\IconSize;

$form
    ->schema([
        TableSelect::make('clients')
            ->relationship('clients', 'name')
            ->multiple()
            ->optionIconSize(IconSize::Large)
    ])
```

---

Selection Table
---------------

[](#selection-table)

### Selection Table Configuration

[](#selection-table-configuration)

You can configure the Selection table by passing a closure into the `selectionTable()` method, this is where you can add columns, remove actions, modify the table's query etc.

Configuring the table is really important, especially defining the table columns. Without explicitly defining table columns, you would be presented with an empty table.

```
use Dvarilek\FilamentTableSelect\Components\Form\TableSelect;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;

TableSelect::make('clients')
    ->relationship('clients', 'name')
    ->selectionTable(function (Table $table) {
        return $table
            ->heading('Active Clients')
            ->columns([
                TextColumn::make('name')
            ])
            ->modifyQueryUsing(fn (Builder $query) => $query->where('status', 'active'));
    })
```

Important

The context of this `selectionTable` callback is scoped to the Livewire component instance where it's evaluated. You cannot inject Filament utilities like `Get $get` or `Set $set` here. To use outside context within this closure, [see here](#working-with-arguments-within-selection-table)

To use an already defined table from a Filament Resource, use the `tableLocation()` method, this can be done together with `selectionTable()`:

```
use Dvarilek\FilamentTableSelect\Components\Form\TableSelect;

TableSelect::make('clients')
    ->relationship('clients', 'name')
    ->tableLocation(ClientResource::class)
```

#### Working with arguments within Selection Table

[](#working-with-arguments-within-selection-table)

To bring outside context into the `selectionTable` Closure, use the `selectionTableArguments` method.

Suppose we have a Project Resource and a project record that can be associated with multiple employees. This Project belongs to a specific Branch. Employees also belong to branches, so we want to limit the employee selection to only those in the same branch as the Project.

```
use Dvarilek\FilamentTableSelect\Components\Form\TableSelect;
use Dvarilek\FilamentTableSelect\Components\Livewire\SelectionTable;
use Illuminate\Database\Eloquent\Builder;
use Filament\Tables\Table;
use Filament\Forms\Get;

TableSelect::make('employees')
    ->relationship('employees', 'name')
    ->multiple()
    ->selectionTableArguments(function (Get $get) {
        return [
            // Suppose there is a branch_id field present in the schema
            'branch_id' => $get('branch_id'),
        ];
    })
    ->tableLocation(EmployeeResource::class)
    ->selectionTable(fn (Table $table) => $table
        ->modifyQueryUsing(function (Builder $query, SelectionTable $livewire) {
            $branchId = $livewire->arguments['branch_id'] ?? null;

            if ($branchId) {
                $query->where('branch_id', $branchId);
            }

            return $query;
        })
    )
```

If you want to replace the Livewire component entirely, use the `selectionTableLivewire` method and provide a subclass of `SelectionTable::class`. This is useful if you rely on other external packages that require you to, for example, add traits to livewire components for functionality.

```
use Dvarilek\FilamentTableSelect\Components\Form\TableSelect;

TableSelect::make('clients')
    ->relationship('clients', 'name')
    ->tableLocation(ClientResource::class)
    ->selectionTableLivewire(CustomSelectionTable::class);
```

---

Selection Action
----------------

[](#selection-action)

### Selection Action Configuration

[](#selection-action-configuration)

The selection action and its modal, where the table is contained, can be configured using the `selectionAction()` method:

```
use Dvarilek\FilamentTableSelect\Components\Form\TableSelect;
use Filament\Forms\Components\Actions\Action;

TableSelect::make('clients')
    ->relationship('clients', 'name')
    ->selectionAction(function (Action $action) {
        return $action
            ->icon('heroicon-o-user-plus')
            ->modalHeading('Select Clients')
            ->slideOver(false);
    })
```

### Selection Action Position

[](#selection-action-position)

By default, the selection action is displayed in the left bottom corner. To change its position, use the `selectionActionAlignment()` method:

```
use Dvarilek\FilamentTableSelect\Components\Form\TableSelect;
use Filament\Forms\Components\Actions\Action;
use Filament\Support\Enums\Alignment;

TableSelect::make('clients')
    ->relationship('clients', 'name')
    ->selectionAction(function (Action $action) {
        return $action
            ->icon('heroicon-o-user-plus')
            ->modalHeading('Select Clients')
            ->slideOver(false);
    })
    ->selectionActionAlignment(Alignment::End)
```

Or provide an optional parameter directly in the `selectionAction()` method:

```
use Filament\Support\Enums\Alignment;

->selectionAction(alignment: Alignment::Center)
```

### Opening Selection Modal On Click

[](#opening-selection-modal-on-click)

If you with to hide this action and open the modal by clicking on the Field directly, use the `triggerSelectionActionOnInputClick()` method:

```
use Dvarilek\FilamentTableSelect\Components\Form\TableSelect;
use Filament\Forms\Components\Actions\Action;

TableSelect::make('clients')
    ->relationship('clients', 'name')
    ->selectionAction(function (Action $action) {
        return $action
            ->icon('heroicon-o-user-plus')
            ->modalHeading('Select Clients')
            ->slideOver(false);
    })
    ->triggerSelectionActionOnInputClick()
```

    open-on-click.mp4    Or provide an optional parameter directly in the `selectionAction()` method:

```
    ->selectionAction(shouldTriggerSelectionActionOnInputClick: true)
```

Note

Having this feature enabled still requires the selection action itself to be visible, because it needs to get mounted.

---

Confirmation action
-------------------

[](#confirmation-action)

### Selection Confirmation

[](#selection-confirmation)

By default, the component's state is automatically updated as records are selected. To require a confirmation of the selection, use the `requiresSelectionConfirmation()` method:

```
use Dvarilek\FilamentTableSelect\Components\Form\TableSelect;

TableSelect::make('clients')
    ->relationship('clients', 'name')
    ->requiresSelectionConfirmation();
```

This prevents automatic state updates and adds a confirmation action to the modal. Only when this action is clicked will the form component's state get updated.

    selection-confirmation.mp4    Important

If you're concerned about performance, especially when updating the state would load a large number of models (e.g., when using one of the getOptionFromRecord methods), consider enabling this feature.

### Closing After Selection

[](#closing-after-selection)

After confirmation, the modal closes by default. To keep it open, use the `shouldCloseAfterSelection()`:

```
use Dvarilek\FilamentTableSelect\Components\Form\TableSelect;

TableSelect::make('clients')
    ->relationship('clients', 'name')
    ->requiresSelectionConfirmation()
    ->shouldCloseAfterSelection(false);
```

Or provide an optional parameter directly in the `requiresSelectionConfirmation()` method:

```
->requiresSelectionConfirmation(shouldCloseAfterSelection: false)
```

Note

Obviously, this only takes effect when selection confirmation is enabled.

### Selection Action Position

[](#selection-action-position-1)

By default, the confirmation action is positioned in the bottom left corner of the modal. To change its position use the `confirmationActionPosition()` method:

```
use Dvarilek\FilamentTableSelect\Components\Form\TableSelect;
use Dvarilek\FilamentTableSelect\Enums\SelectionModalActionPosition;

TableSelect::make('clients')
    ->relationship('clients', 'name')
    ->requiresSelectionConfirmation()
    ->confirmationActionPosition(SelectionModalActionPosition::TOP_LEFT);
```

Or provide an optional parameter directly in the `requiresSelectionConfirmation()` method:

```
use Dvarilek\FilamentTableSelect\Enums\SelectionModalActionPosition;

->requiresSelectionConfirmation(confirmationActionPosition: SelectionModalActionPosition::TOP_LEFT)
```

---

Creating New Records
--------------------

[](#creating-new-records)

### Create Option Action

[](#create-option-action)

In a standard Select field, if users can’t find the record they need, they can create and associate a new one on using the `createOptionAction()`. - [Official Filament Documentation](https://filamentphp.com/docs/3.x/forms/fields/select#creating-a-new-option-in-a-modal)

The TableSelect borrows this exact functionality and displays the create option action in the selection modal. To configure this action you can use the following methods:

```
use Dvarilek\FilamentTableSelect\Components\Form\TableSelect;

TableSelect::make('clients')
    ->relationship('clients', 'name')
    ->createOptionForm(ClientResource::form(...))
    ->createOptionUsing(function (array $data) {
        // Create related record using...
    })
    ->createOptionAction(function () {
        // Configure the action...
    })
```

    create-option.mp4    Important

When a new record is created, it's automatically selected in the table. If this newly created record exceeds the selection limit, the record naturally won't be selected. Obviously, in single-selection mode, the new record will replace the old one.

### Create Option Action Position

[](#create-option-action-position)

By default, the create option action is positioned in the top right corner of the modal. To change its position use the `createOptionActionPosition()` method:

```
use Dvarilek\FilamentTableSelect\Components\Form\TableSelect;
use Dvarilek\FilamentTableSelect\Enums\SelectionModalActionPosition;
use Filament\Forms\Form;

TableSelect::make('clients')
    ->relationship('clients', 'name')
    ->createOptionForm(fn (Form $form) => ClientResource::form($form))
    ->createOptionActionPosition(SelectionModalActionPosition::TOP_LEFT)
```

---

Advanced
--------

[](#advanced)

To globally configure all TableSelect component instances, use the `configureUsing()` method in you application's Service Provider boot method:

```
use Dvarilek\FilamentTableSelect\Components\Form\TableSelect;

public function boot(): void
{
    TableSelect::configureUsing(static function (TableSelect $tableSelect): void {
        $tableSelect->requiresSelectionConfirmation();
    });
}
```

---

Testing
-------

[](#testing)

```
composer test
```

---

Changelog
---------

[](#changelog)

Please refer to [Package Releases](https://github.com/dvarilek/table-select/releases) for more information about changes.

---

License
-------

[](#license)

This package is under the MIT License. Please refer to [License File](https://github.com/dvarilek/filament-table-select/blob/main/LICENSE.md) for more information

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance56

Moderate activity, may be stable

Popularity38

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 96% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~8 days

Total

11

Last Release

280d ago

Major Versions

v1.1.0 → v2.0.02025-06-04

### Community

Maintainers

![](https://www.gravatar.com/avatar/df6b14ab735d5da2e87d2279af19cbfd84cc54d7ca06ef36606b64bf5621e42f?d=identicon)[dvarilek](/maintainers/dvarilek)

---

Top Contributors

[![dvarilek](https://avatars.githubusercontent.com/u/93047221?v=4)](https://github.com/dvarilek "dvarilek (121 commits)")[![jeffersongoncalves](https://avatars.githubusercontent.com/u/411493?v=4)](https://github.com/jeffersongoncalves "jeffersongoncalves (4 commits)")[![elmergustavo](https://avatars.githubusercontent.com/u/42653934?v=4)](https://github.com/elmergustavo "elmergustavo (1 commits)")

---

Tags

selecttablefilament

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/dvarilek-filament-table-select/health.svg)

```
[![Health](https://phpackages.com/badges/dvarilek-filament-table-select/health.svg)](https://phpackages.com/packages/dvarilek-filament-table-select)
```

###  Alternatives

[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[ysfkaya/filament-phone-input

A phone input component for Laravel Filament

299998.0k20](/packages/ysfkaya-filament-phone-input)[awcodes/filament-curator

A media picker plugin for FilamentPHP.

434297.7k19](/packages/awcodes-filament-curator)[shuvroroy/filament-spatie-laravel-backup

This plugin is built on top of Spatie's Laravel-backup package

268356.4k6](/packages/shuvroroy-filament-spatie-laravel-backup)[pboivin/filament-peek

Full-screen page preview modal for Filament

253319.6k12](/packages/pboivin-filament-peek)[croustibat/filament-jobs-monitor

Background Jobs monitoring like Horizon for all drivers for FilamentPHP

254255.2k6](/packages/croustibat-filament-jobs-monitor)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
