hungrybus / filament-custom-fields
This plugin allows to create custom fields via front-end
Fund package maintenance!
HungryBus
Requires
- php: ^8.1
- filament/filament: ^3.0
- spatie/laravel-package-tools: ^1.15.0
- vicmans/filament-number-input: ^1.0
Requires (Dev)
- laravel/pint: ^1.20
- nunomaduro/collision: ^7.9
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^8.0
- pestphp/pest: ^2.1
- pestphp/pest-plugin-arch: ^2.0
- pestphp/pest-plugin-laravel: ^2.0
- phpstan/extension-installer: ^1.1
- phpstan/phpstan: ^1.12
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
This package is auto-updated.
Last update: 2025-06-16 10:02:57 UTC
README
Filament Custom Fields is a plugin for Laravel Filament that allows you to add custom fields to your Filament resources.
Installation
You can install the package via composer:
composer require hungrybus/filament-custom-fields
You can publish and run the migrations with:
php artisan vendor:publish --provider="HungryBus\FilamentCustomFields\FilamentCustomFieldsServiceProvider"
After publishing the migration files, run the migrations:
php artisan migrate
Configuration
The package provides a configuration file located at config/custom-fields.php
.
In this file, you can specify the resources and models that will utilize custom fields. For example:
<?php use HungryBus\FilamentCustomFields\Resources\CustomFieldResource; use HungryBus\FilamentCustomFields\Resources\CustomFieldResponseResource; return [ 'resources' => [ CustomFieldResource::class, CustomFieldResponseResource::class, ], // Models that will have custom fields 'models' => [ // \App\Models\YourModel::class => 'your_model', ], 'navigation_group' => 'Custom Fields', 'custom_fields_label' => 'Custom Fields', 'custom_field_responses_label' => 'Custom Field Responses', ];
Usage
In order to save and/or display custom fields for a model, you need to add the HasCustomData
trait to the model:
use HungryBus\FilamentCustomFields\Traits\HasCustomData; class Vehicle extends Model { use HasCustomData; }
If you have multi-tenancy enabled, you can specify the tenant column in the model:
// Company is a tenant model class Company extends \Illuminate\Database\Eloquent\Model { use \HungryBus\CustomFields\Concerns\HasTenantCustomFields; }
Displaying Custom Field Responses
To display custom field responses in a resource's table, add the custom fields column:
use HungryBus\FilamentCustomFields\CustomFields\FilamentCustomFieldsHelper; public static function table(Table $table): Table { $columns = [ // Your existing columns ]; return $table ->columns([ // Your existing columns FieldsService::buildTable(Vehicle::class, $columns)) ]); }
Displaying Custom Field Responses in a Form
To display custom field responses in a form, add the custom fields to the form:
return $form->schema([ // Your existing fields \HungryBus\CustomFields\Services\FieldsService::buildForm(Vehicle::class) ]);
In Create page, add the CreatesWithCustomData
trait to the resource:
class CreateVehicle extends \Filament\Resources\Pages\CreateRecord { use CreatesWithCustomData; }
Then, in the Edit page, add the UpdatesWithCustomData
trait to the resource:
class EditVehicle extends \Filament\Resources\Pages\EditRecord { use UpdatesWithCustomData; }
Displaying Custom Field Responses in Infolist
To display custom field responses in an infolist, add the custom fields to the infolist:
return $infolist->schema([ // Your existing fields \HungryBus\CustomFields\Services\FieldsService::buildInfolist(Vehicle::class) ]);
Credits
This package is developed and maintained by HungryBus.
Disclaimer
This is my very first open-source package. I am still learning the open-source topic, and I am open to any constructive feedback or suggestions. Please feel free to open an issue to express an opinion or ask a question. If you think you can help this package to grow, please feel free to open a pull request.
Due to my job and some personal stuff, I am extremely busy at the moment, and it is quite hard to me to find time to work on this on everyday basis. I will try to find time to work on this package as much as I can.
License
The MIT License (MIT). Please see License File for more information.