avnsh1111/filament-dynamic-form-builder
Installation
composer require avnsh1111/filament-dynamic-form-builder
php artisan vendor:publish --tag=filament-dfb-config
php artisan vendor:publish --tag=filament-dfb-migrations
php artisan migrate
php artisan filament:assets
Register the plugin in your PanelProvider:
public function panel(Panel $panel): Panel
{
return $panel->plugin(DynamicFormBuilderPlugin::make());
}
Access the Builder
Navigate to /admin/forms in your Filament panel to create your first dynamic form.
Design a Form
class="required").First Render Use the runtime renderer in a Blade view:
<livewire:av-dynamic-form slug="your-form-slug" />
Replace your-form-slug with the slug of your saved form.
name, email, message (textarea)./admin/forms).
Grid, Columns, or Stack layouts for responsive design.TextInput, RichEditor, FileUpload) plus custom attributes (e.g., data-validation="required").<livewire:av-dynamic-form
slug="contact-us"
submit-button-label="Send Message"
success-message="Thanks! We'll get back to you soon."
/>
slug: Required (links to the saved form).submit_button_label: Customize the submit button text.success_message: Override the default success message.honeypot_enabled: Disable if not using spam protection.custom_html_attributes in the builder to add Tailwind/CSS classes or data-* attributes.dynamic_form_entries table (with timestamps, IP, user agent).{entry.name})./admin/forms/{slug}/entries.use Avnsh1111\FilamentDynamicFormBuilder\Models\Entry;
$entries = Entry::where('form_slug', 'contact-us')->latest()->get();
use Avnsh1111\FilamentDynamicFormBuilder\Widgets\DynamicFormWidget;
public static function getWidgets(): array
{
return [
DynamicFormWidget::make('Feedback')
->slug('feedback-form')
->columnSpanFull(),
];
}
form_updated event to sync external data:
event(new \Avnsh1111\FilamentDynamicFormBuilder\Events\FormUpdated($form));
PhoneInput) by extending Filament\Forms\Components\Field and register it in the builder:
// config/filament-dfb.php
'fields' => [
\App\Filament\Forms\Components\PhoneInput::class,
],
storage/app/public/dynamic-form-uploads/{form_slug}/.filament:assets is run after publishing migrations.Slug Conflicts:
slug for routing. Ensure uniqueness across the system.Email Template Parsing:
{entry.field_name} syntax fails if field_name has spaces or special chars.first_name instead of first name) or sanitize in the template:
// Override the email template logic in a service provider
Event::listen(FormSubmitted::class, function ($event) {
$event->template = str_replace(['{entry.' => '{entry->'], $event->template);
});
Livewire Component Not Loading:
filament:assets or incorrect Livewire namespace.php artisan filament:assets
Verify the component is registered in resources/js/app.js:
import './filament';
File Upload Limits:
upload_max_filesize or post_max_size..env:
UPLOAD_MAX_SIZE=20M
POST_MAX_SIZE=25M
Honeypot Bypass:
display: none !important; in your form’s CSS.Form Not Rendering:
slug matches a published form in the database:
SELECT * FROM `dynamic_forms` WHERE `slug` = 'your-slug';
Email Not Sending:
tail -f storage/logs/laravel.log | grep "Swift_"
Database Issues:
php artisan migrate:fresh --env=local
Custom Entry Model:
Entry model to add fields (e.g., status):
php artisan make:model DynamicFormEntryExtension --extend=Avnsh1111\FilamentDynamicFormBuilder\Models\Entry
config/filament-dfb.php:
'entry_model' => \App\Models\DynamicFormEntryExtension::class,
Pre/Post Submission Hooks:
use Avnsh1111\FilamentDynamicFormBuilder\Events\FormSubmitted;
Event::listen(FormSubmitted::class, function ($event) {
// Log submission or trigger a webhook
Log::info('Form submitted', $event->entry->toArray());
});
Dynamic Form Fields via API:
Route::get('/api/forms/{slug}', [DynamicFormController::class, 'showSchema']);
Multi-Language Support:
Form model to add a locale field and translate field labels:
use Spatie\Translatable\HasTranslations;
class DynamicForm extends Model
{
use HasTranslations;
public $translatable = ['title', 'description'];
}
How can I help you explore Laravel packages today?