Download the PHP package dvarilek/filament-table-select without Composer

On this page you can find all versions of the php package dvarilek/filament-table-select. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package filament-table-select

Filament Table Select

[![Latest Version on Packagist](https://img.shields.io/packagist/v/dvarilek/filament-table-select.svg?include_prereleases)](https://packagist.org/packages/dvarilek/filament-table-select) [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE.md) [![Total Downloads](https://img.shields.io/packagist/dt/dvarilek/filament-table-select.svg)](https://packagist.org/packages/dvarilek/filament-table-select)
Filament Table Select Banner

Installation


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.


[!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


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.


Multi Selection

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


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:

[!NOTE]\ If maxItems(1) is set to 1, radio-like selection gets enabled regardless of the relationship type.



Customizing Selected Options

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:

Filament Table Option Color Configuration


To customize the icon of selected options, use the optionIcon() method:

Filament Table Select Option Icon Configuration


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.

Filament Table Select Option Color Configuration 2


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

Filament Table Select Option Icon Configuration 2


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

Filament Table Select Option Label Configuration


Other Configuration Options

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

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


Selection Table

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.

[!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

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


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.


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.


Selection Action

Selection Action Configuration

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


Selection Action Position

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

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


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:

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

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



Confirmation action

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:

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.

[!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

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

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

[!NOTE]\ Obviously, this only takes effect when selection confirmation is enabled.


Selection Action Position

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

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



Creating New Records

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

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:

[!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

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



Advanced

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


Testing


Changelog

Please refer to Package Releases for more information about changes.


License

This package is under the MIT License. Please refer to License File for more information


All versions of filament-table-select with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2|^8.3|^8.4
spatie/laravel-package-tools Version ^1.18
filament/filament Version ^3.0
dvarilek/livewire-closure-synthesizer Version ^1.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package dvarilek/filament-table-select contains the following files

Loading the files please wait ...