Nested Builder Form Field
CommunityAdd nested Builder to your forms
Author:
Georges OLIVARES
Package health
BetaAutomated checks of this plugin's Composer package
15 checks
- Failed: GitHub Actions pinned to SHA — View details on Plumb
- Skipped: GitLab CI includes pinned to SHA
- Passed: Open security advisories
- Failed: Dependabot PR responsiveness — Stale Dependabot PRs: oldest general PR is 1021 days old. View details on Plumb
- Skipped: Renovate MR responsiveness
- Passed: Dependabot or Renovate configured
-
Failed:
Dependency update cooldown configured
—
No cooldown configured in
.github/dependabot.yml. View details on Plumb - Passed: Provides a security policy
- Passed: Abandoned or archived — No consulted source marks the package abandoned (packagist, github).
- Failed: Commit and release recency — Inactive: last commit 832 days ago; last release 1046 days ago. View details on Plumb
-
Passed:
composer.lock not committed by library
—
composer.lockis absent from the released dist archive. - Passed: Dist archive is lean
- Skipped: Current Laravel version supported
-
Passed:
Current PHP version supported
—
Constraint
^8.1supports current PHP8.5. - Skipped: Current Symfony version supported
filament/
namespace. Review the source and install at your own risk. Found
malware or an unresolved security issue the author won't
address?
Report it
.
Documentation
Filament V3 Form plugin. Add a new feature for Nested Builder.
#Installation
You can install the package via composer:
composer require thiktak/filament-nested-builder-form
#Usage
On any Form :
- Call
NestedBuilderinstead ofBuilder - All all your Builder configuration inside
nestedConfiguration(Closure). - Use
nestedSchema(Closure)instad ofschema(Closure | array)
Use $builder->getLevel() of NestedSubBuilder to know where you are (level 1 to n)
Note:
- NestedBuilder like Builder works with an array/json data.
use Thiktak\FilamentNestedBuilderForm\Forms\Components\NestedBuilder;
use Thiktak\FilamentNestedBuilderForm\Forms\Components\NestedSubBuilder;
// ...
NestedBuilder::make('array_configuration')
// Add configuration to Builder & sub-builder
->nestedConfiguration(function (NestedSubBuilder $builder) {
// Apply only for the root level
$builder->blockNumbers($builder->getLevel() == 1);
// Apply for all others levels
$builder->columnSpanFull(); // full width
})
// Replace schema() by nestedSchema
->nestedSchema(function (NestedSubBuilder $builder) { // Closure is mandatory
return [
Block::make('group')
->schema([
Select::make('title')
->required(),
// Call builder importer and call it children
$builder->importNestedBlocks('children'),
]),
Block::make('rule')
->schema([
TextInput::make('field')
->required(),
])
];
});
#Example
One concrete example of this package, allow you to create a nested AND/OR field/condition/value like complexe group SQL queries.
use Thiktak\FilamentNestedBuilderForm\Forms\Components\NestedBuilder;
use Thiktak\FilamentNestedBuilderForm\Forms\Components\NestedSubBuilder;
// ...
NestedBuilder::make('array_configuration')
->nestedConfiguration(function (NestedSubBuilder $builder) {
$builder->blockNumbers($builder->getLevel() == 1);
$builder->columnSpanFull(); // full width
})
->nestedSchema(function (NestedSubBuilder $builder) {
return [
Block::make('group')
->label(sprintf('Group (%s)', $builder->getLevel()))
->schema([
Select::make('condition')
->options(['and' => 'AND', 'or' => 'OR'])
->default('and')
->required(),
$builder->importNestedBlocks('children'),
])
->columns(1),
Block::make('rule')
->label(sprintf('Rule (%s)', $builder->getLevel()))
->schema([
TextInput::make('field')
->required()
->columnSpan(2),
Select::make('sign')
->options(['=', '<>', '>', '<', 'in(,)'])
->default('=')
->required(),
TextInput::make('value')
->columnSpan(3),
])
->columns(6)
];
});
#Example of advanced usage of this package:
#How it work ?
You can achieve the same behavior with few lines of code.
- Create a function with your builder (
$nested = fn($builder) => [...];) - On your schema, pass the function that call itself inside a lambda function (
fn() => $nested($nested)). - On you builder function, add a new Builder with identical logic (
Builder::make()->schema(fn() => $builder($builder)))
Example:
use Thiktak\FilamentNestedBuilderForm\Forms\Components\NestedBuilder;
use Thiktak\FilamentNestedBuilderForm\Forms\Components\NestedSubBuilder;
// ...
public static function form(Form $form): Form
{
$nested = function ($builder) {
return [
Block::make('group')
->schema([
Select::make('condition')
->options(['and' => 'AND', 'or' => 'OR'])
->default('and')
->required(),
\Filament\Forms\Components\Builder::make('children')
->schema(fn () => $builder($builder))
])
->columns(1),
Block::make('rule')
->schema([
TextInput::make('field')
->required()
->columnSpan(2),
Select::make('sign')
->options(['=', '<>', '>', '<', 'in(,)'])
->default('=')
->required(),
TextInput::make('value')
->columnSpan(3),
])
->columns(6)
];
};
return $form
->schema([
\Filament\Forms\Components\Builder::make('array_configuration')
->schema(fn () => $nested($nested))
]);
}
Use thiktak/filament-nested-builder-form if you want to implement a rich SQL selector & query builder.
#Testing
composer test
#Changelog
Please see CHANGELOG for more information on what has changed recently.
#Contributing
Please see CONTRIBUTING for details.
#Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
#Credits
#License
The MIT License (MIT). Please see License File for more information.
The author
From the same author
Featured Plugins
A selection of plugins curated by the Filament team
Custom Dashboards
Let your users build and share their own dashboards with a drag-and-drop interface. Define your data sources in PHP and let them do the rest.
Filament
Spotlight Pro
Browse your Filament Panel with ease. Filament Spotlight Pro adds a Spotlight/Raycast like Command Palette to your Filament Panel.
Dennis Koch
Blueprint
Filament Blueprint is a premium Laravel Boost extension that helps AI agents produce accurate, detailed implementation plans and security reports for Filament apps.
Filament