Filament Field Group is a powerful Laravel package that enhances Filament's form building capabilities. It allows you to easily group and organize form fields, improving the structure and readability of your forms. With this package, you can create collapsible sections, tabs, or custom layouts for your form fields, making complex forms more manageable and user-friendly.
- You can install the package via composer:
composer require solution-forest/filament-field-group
- Register the plugin in your Panel provider
use SolutionForest\FilamentFieldGroup\FilamentFieldGroupPlugin; class AdminPanelProvider extends PanelProvider { public function panel(Panel $panel): Panel { return $panel ->plugin(FilamentFieldGroupPlugin::make()); } }
- Then execute the following commands:
php artisan filament-field-group:install
You can publish and run the migrations with:
php artisan vendor:publish --tag="filament-field-group-migrations"
php artisan migrate
You can publish the config file with:
php artisan vendor:publish --tag="filament-field-group-config"
Optionally, you can publish the views using
php artisan vendor:publish --tag="filament-field-group-views"
This is the contents of the published config file:
return [
'enabled' => false,
'models' => [
'field' => \SolutionForest\FilamentFieldGroup\Models\Field::class,
'field_group' => SolutionForest\FilamentFieldGroup\Models\FieldGroup::class,
],
'table_names' => [
'fields' => 'advanced_fields',
'field_groups' => 'advanced_field_groups',
],
];
- Add
FilamentFieldGroupPlugin
to you panel. - Enable the Field Group resource by setting
enabled
totrue
in the config file:
// config/filament-field-group.php
return [
'enabled' => true,
// ... other config options
];
Or enable the plugin on FilamentFieldGroupPlugin
use SolutionForest\FilamentFieldGroup\FilamentFieldGroupPlugin;
$panel
->plugin(FilamentFieldGroupPlugin::make()->enablePlugin());
-
Create field groups and fields, for example:
-
Apply field groups to your form schema:
use SolutionForest\FilamentFieldGroup\Facades\FilamentFieldGroup;
public static function form(Form $form): Form
{
return $form
->columns(1)
->schema([
FilamentFieldGroup::findFieldGroup('user_basic'),
FilamentFieldGroup::findFieldGroup('user_detail'),
]);
}
Currently, this package provides the following components:
- Text
- TextArea
- Password
- Number
- Url
- Select
More components can be added in the future. Feel free to submit a pull request if you have ideas for additional components!
You can call resources
on FilamentFieldGroupPlugin
to add/replace original resource:
use SolutionForest\FilamentFieldGroup\FilamentFieldGroupPlugin;
$panel
->plugin(FilamentFieldGroupPlugin::make()
->resources([
// your resource
], override: true)
);
You can add or replace original field type configurations using the fieldTypeConfigs
method on either FilamentFieldGroupPlugin
or FilamentFieldGroup
. Here are two options:
use SolutionForest\FilamentFieldGroup\FilamentFieldGroupPlugin;
$panel
->plugin(FilamentFieldGroupPlugin::make()
->fieldTypeConfigs([
// your field type config
], override: true)
);
public function boot(): void
{
\SolutionForest\FilamentFieldGroup\Facades\FilamentFieldGroup::fieldTypeConfigs([
\Your\Custom\FieldType::class
], override: true);
}
This section allows you to customize the model used for field groups in the Filament Field Group package. By replacing the default FieldGroup
model with your own implementation, you can extend or modify its behavior to suit your application's needs.
To do this, use the setFieldGroupModelClass
or setFieldModelClass
methods from the FilamentFieldGroup
facade, specifying the original model and your custom model. Here's an example:
\SolutionForest\FilamentFieldGroup\Facades\FilamentFieldGroup::setFieldGroupModelClass(
Your\Models\FieldGroup::class
);
\SolutionForest\FilamentFieldGroup\Facades\FilamentFieldGroup::setFieldModelClass(
Your\Models\Field::class
);
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
We welcome contributions to enhance this package. More components can potentially be added, so feel free to submit a pull request with your ideas or improvements.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.