Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Filament Select Tree

Filament Select Tree Laravel Package

codewithdennis/filament-select-tree

Add a dynamic select tree field to Laravel and Filament apps. Build interactive hierarchical selection dropdowns from BelongsTo or BelongsToMany relationships, or custom queries. Customize parent and child queries, and toggle strict null-parent root nodes.

View on GitHub
Deep Wiki
Context7

The multi-level select field enables you to make single selections from a predefined list of options that are organized into multiple levels or depths.

Frequently asked questions about Filament Select Tree
How do I install filament-select-tree in a Laravel app?
Run composer require codewithdennis/filament-select-tree:4.x and then php artisan filament:assets to publish the front-end assets the tree field needs. No migrations or config publishing are required because the package consumes your existing relationships or queries. After that you can drop SelectTree::make('category_id') into any Filament form or filter.
Does filament-select-tree work with Filament 3 and Filament 4?
Version 4.x of the package targets Filament 4, so install it with the :4.x constraint on a Filament 4 application. If you are still on Filament 3.x you must use the separate 3.x branch of the package instead, which is a version-skew trap worth pinning explicitly in composer.json. There is no published timeline for Filament 5 support, so treat framework upgrades as a scheduled dependency task.
How do I build a hierarchical select from a BelongsTo or BelongsToMany relationship?
Pass the relationship name, the title column and the parent column to the relationship() method, for example SelectTree::make('categories')->relationship('categories', 'name', 'parent_id'). A BelongsToMany relationship gives you a multi-select tree, while a BelongsTo relationship gives a single selection. The parent column is what turns a flat table into a tree, so it should point at the record's own parent key.
Can I use SelectTree without an Eloquent relationship?
Yes. Use the query() method and pass a closure that returns a query builder along with the title and parent attributes, for example SelectTree::make('category_id')->query(fn () => Category::query(), 'name', 'parent_id'). This is useful for shared taxonomies that are not directly related to the form's model. For fully bespoke trees you can bypass the package queries entirely with getTreeUsing() and hand it your own array.
How do I filter the tree options with a custom query?
Use modifyQueryUsing to constrain the parent query and modifyChildQueryUsing to constrain the child query, both of which receive the query builder in a closure. That keeps scoping, ordering and soft-delete rules inside your own code rather than the package's. Note that these closures are evaluated deferred, so keep them side-effect free.
How do I allow multiple selections in the tree field?
Attaching the field to a BelongsToMany relationship gives you multiple selection by default, since the field stores an array of keys. For single-record setups you can enable multiple selection on the field itself. If your downstream queries expect leaf IDs, remember that selecting a branch node stores the parent key, which may not be what your application expects.
What does strictNullParentRootNodes do and why are children promoted to root?
When you filter the parent query, any child row whose parent was filtered out is promoted to a root node by default so the dropdown never renders an empty result set. That behaviour is convenient but silent, and it can surface records you thought were excluded. Call strictNullParentRootNodes() to disable it and drop the orphaned branches instead.
Is filament-select-tree fast enough for large trees, and does it lazy load nodes?
The whole tree is assembled per render, and helpers like withCount() and storeResults() add to that cost, so a Livewire re-render on a taxonomy with thousands of nodes can be a real performance cliff. There is no documented async or lazy loading of nodes and no documented caching story. For very large trees, narrow the queries with modifyQueryUsing or build the array yourself via getTreeUsing().
How do I keep multi-tenant data out of a SelectTree dropdown?
The package applies no scoping for you: if you hand it a raw query through query() or modifyQueryUsing, you must add the tenant constraint yourself. Relying on a global scope on the model is safer, but it should be verified with a test that renders the field while authenticated as another tenant. Also watch for cyclic parent chains and deep trees, which can produce slow or incorrect output.
Who maintains filament-select-tree and is it safe for production?
It is effectively a single-maintainer package by CodeWithDennis, with community pull requests and mostly dependency-bump releases. There is no documented test suite or coverage badge, and the README is the only specification beyond the source. That means a low blast radius, since the field only affects the forms where you explicitly use it, but you should write your own integration tests and track the Filament 5 upgrade in your dependency plan.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
elmogy/larafast
xeviant/laravel-paystack
gorilladash/laravel-website-sdk
martialbe/flysystem-oss
chondal/3312client
jeroen-g/flickr
opscale-co/nova-genbi
itsjustvita/laravel-retention
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log
gregsphotography/site-builder-components
io-digital/clickatell
snowsoft/laravel-admin
oxygen/auth
relicsoftware/barakah-payment-gateway
tobya/work-with-composer
equipc/laravel-email-validator
equipc/laravel-email-database-log
adedsec/nova-translated-labels