A Filament package to manage adjacency lists (aka trees).
You can install the package via composer:
composer require saade/filament-adjacency-list
use Saade\FilamentAdjacencyList\Forms\Components\AdjacencyList;
AdjacencyList::make('subjects')
->form([
Forms\Components\TextInput::make('label')
->required(),
])
AdjacencyList::make('subjects')
->labelKey('name') // defaults to 'label'
->childrenKey('subitems') // defaults to 'children'
AdjacencyList::make('subjects')
->maxDepth(2) // defaults to -1 (unlimited depth)
AdjacencyList::make('subjects')
->modal(false) // defaults to true
AdjacencyList::make('subjects')
->addable(false)
->editable(false)
->deletable(false)
->reorderable(false)
use Filament\Forms\Actions\Action;
AdjacencyList::make('subjects')
->addAction(fn (Action $action): Action => $action->icon('heroicon-o-plus')->color('primary'))
->addChildAction(fn (Action $action): Action => $action->button())
->editAction(fn (Action $action): Action => $action->icon('heroicon-o-pencil'))
->deleteAction(fn (Action $action): Action => $action->requiresConfirmation())
->reorderAction(fn (Action $action): Action => $action->icon('heroicon-o-arrow-path-rounded-square'))
Important
Reorder Action
If you want to add ->extraAttributes()
to the action, you need to add the ['data-sortable-handle' => 'true']
attribute to the array.
if you want to trigger a livewire action on click, you need to chain ->livewireClickHandlerEnabled()
on the action.
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
- Saade
- Ryan Chandler's Navigation Plugin for the inspiration.
- All Contributors
The MIT License (MIT). Please see License File for more information.