A Filament plugin and package that allows the creation of forms via the admin panel for collecting user data on the front end. Forms are composed of filament field components and support all Laravel validation rules. Form responses can be rendered on the front end of exported to .csv.
- PHP 8.2+
- Laravel 11.0+
- Filament 4.x / 5.x
| Filament | Filament Form Builder | Documentation |
|---|---|---|
| 4.x/5.x | 4.x | Current |
| 3.x | 1.x | Check the docs |
Install the plugin via Composer:
This package is not yet on Packagist. Add the repository to your composer.json
{
"repositories": [
{
"type": "vcs",
"url": "https://github.com/TappNetwork/Filament-Form-Builder"
}
],
}composer require tapp/filament-form-builder:"^4.0"You can publish the migrations with:
php artisan vendor:publish --tag="filament-form-builder-migrations"Warning
If you are using multi-tenancy please see the "Multi-Tenancy Support" instructions below before publishing and running migrations.
You can run the migrations with:
php artisan migrateYou can publish the view file with:
php artisan vendor:publish --tag="filament-form-builder-views"You can publish the config file with:
php artisan vendor:publish --tag="filament-form-builder-config"Add this plugin to a panel on plugins() method (e.g. in app/Providers/Filament/AdminPanelProvider.php).
use Tapp\FilamentFormBuilder\FilamentFormBuilderPlugin;
public function panel(Panel $panel): Panel
{
return $panel
// ...
->plugins([
FilamentFormBuilderPlugin::make(),
//...
]);
}Add this to your tailwind.config.js content section:
content: [
...
"./vendor/tapp/**/*.blade.php",
],
You can disable the redirect when including the Form/Show component inside of another component by passing the 'blockRedirect' prop as follows
@livewire('tapp.filament-form-builder.livewire.filament-form.show', ['form' => $test->form, 'blockRedirect' => true])
This plugin includes comprehensive support for multi-tenancy, allowing you to scope forms, form fields, and entries to specific tenants (e.g., Teams, Organizations, Companies).
You MUST enable and configure tenancy BEFORE running migrations! The migrations check the tenancy configuration to determine whether to add tenant columns to the database tables. Enabling tenancy after running migrations will require manual database modifications.
Update your config/filament-form-builder.php configuration file:
'tenancy' => [
// Enable tenancy support
'enabled' => true,
// The Tenant model class
'model' => \App\Models\Team::class,
// Optional: Override the tenant relationship name
// (defaults to snake_case of tenant model class name: Team -> 'team')
'relationship_name' => null,
// Optional: Override the tenant foreign key column name
// (defaults to relationship_name + '_id': 'team' -> 'team_id')
'column' => null,
],- Configure tenancy in
config/filament-form-builder.php(setenabledtotrueand specify your tenant model) - Publish migrations:
php artisan vendor:publish --tag="filament-form-builder-migrations" - Run migrations:
php artisan migrate - Configure your Filament Panel with tenancy:
use Filament\Panel;
use App\Models\Team;
use Tapp\FilamentFormBuilder\FilamentFormBuilderPlugin;
public function panel(Panel $panel): Panel
{
return $panel
->tenant(Team::class)
->plugins([
FilamentFormBuilderPlugin::make(),
]);
}When tenancy is enabled:
- Automatic Scoping: All queries within Filament panels are automatically scoped to the current tenant
- URL Structure: Forms are accessed via tenant-specific URLs:
/admin/{tenant-slug}/filament-forms - Data Isolation: Each tenant can only access their own forms, fields, and entries
- Cascade Deletion: Deleting a tenant automatically removes all associated form data
To disable tenancy, set enabled to false in your configuration:
'tenancy' => [
'enabled' => false,
'model' => null,
],The FilamentForm/Show component emits an 'entrySaved' event when a form entry is saved. You can handle this event in a parent component to as follows.
class ParentComponent extends Component
{
protected $listeners = ['entrySaved'];
public function entrySaved(FilamentFormUser $survey)
{
// custom logic you would like to add to form entry saving logic
}
}
The component also emits a Laravel event that you can listen to in your event service provider
// In your EventServiceProvider.php
protected $listen = [
\Tapp\FilamentFormBuilder\Events\EntrySaved::class => [
\App\Listeners\HandleFormSubmission::class,
],
];
// Create a listener class
namespace App\Listeners;
use Tapp\FilamentFormBuilder\Events\EntrySaved;
class HandleFormSubmission
{
public function handle(EntrySaved $event): void
{
// Access the form entry
$entry = $event->entry;
// Perform actions with the form data
// For example, send notifications, update other records, etc.
}
}