Solution Forest Web development agency based in Hong Kong. We help customers to solve their problems. We Love Open Soruces.
We have built a collection of best-in-class products:
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.
composer require solution-forest/filament-field-group
use SolutionForest\FilamentFieldGroup\FilamentFieldGroupPlugin; class AdminPanelProvider extends PanelProvider{ public function panel(Panel $panel): Panel { return $panel ->plugin(FilamentFieldGroupPlugin::make()); }}
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', ],];
FilamentFieldGroupPlugin
to you panel.enabled
to true
in the config file: // config/filament-field-group.phpreturn [ '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:
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 your own custom field types by following these steps:
SolutionForest\FilamentFieldGroup\FieldTypes\Configs\FieldTypeBaseConfig
getFormSchema()
which defines the form fields// Option 1: On Your Filament Panel use SolutionForest\FilamentFieldGroup\FilamentFieldGroupPlugin; $panel ->plugin(FilamentFieldGroupPlugin::make() ->fieldTypeConfigs([ // your field type config ], override: true) );
// Option 2: On Your AppServiceProvider use SolutionForest\FilamentFieldGroup\Facades\FilamentFieldGroup; public function boot(): void{ FilamentFieldGroup::fieldTypeConfigs([ \Your\Custom\FieldType::class ], override: true);}
To completely replace all default field types, set the override
parameter to true
.
You can customize the config
form for specific field types by adding your own custom options. This is useful when you need to extend the functionality of existing field types with additional configuration parameters.
// In AppServiceProvider.php boot() methoduse SolutionForest\FilamentFieldGroup\Facades\FilamentFieldGroup; public function boot(): void{ FilamentFieldGroup::configureFieldTypeConfigFormUsing( \SolutionForest\FilamentFieldGroup\FieldTypes\Configs\Text::class, function ($field, array $schema) { return [ ...$schema, // Your additional config form fields Toggle::make('datalist'), // More custom configuration options... ]; } );}
This allows you to modify the configuration form for field types while preserving all the default options.
You can set custom models for field groups and fields in your AppServiceProvider
:
// In AppServiceProvider.php boot() methoduse SolutionForest\FilamentFieldGroup\Facades\FilamentFieldGroup; public function boot(): void{ FilamentFieldGroup::setFieldGroupModelClass(Your\Models\FieldGroup::class); FilamentFieldGroup::setFieldModelClass(Your\Models\Field::class);}
You can extend field type functionality using the mixin
method on FieldTypeBaseConfig
. This allows you to reuse field configuration logic across different field types:
use SolutionForest\FilamentFieldGroup\FieldTypes\Configs\FieldTypeBaseConfig; class MyFieldTypeMixin{ public function addValidationRules() { return function (array $rules = []) { return array_merge($rules, ['required', 'string']); }; } public function addHelperText() { return function () { return 'This is a helper text for all fields using this mixin'; }; }} // Apply the mixin to your field typeFieldTypeBaseConfig::mixin(new MyFieldTypeMixin());
You can also apply mixins to specific field type classes:
use SolutionForest\FilamentFieldGroup\FieldTypes\Configs\Text; // Apply mixin only to Text fieldsText::mixin(new TextFieldSpecificMixin());
This approach helps maintain DRY code by centralizing common field configurations that can be shared across multiple field types.
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.