coolsam / visual-forms
Dynamically and Visually create forms in Filament and collect responses
Fund package maintenance!
coolsam
Requires
- php: ^8.1
- awcodes/filament-table-repeater: ^3.1
- filament/filament: ^3
- spatie/laravel-package-tools: ^1.15.0
Requires (Dev)
- barryvdh/laravel-ide-helper: ^3.5
- laravel/pint: ^1.0
- nunomaduro/larastan: ^3.1.0
- orchestra/testbench: ^9.12
- pestphp/pest-plugin-laravel: ^3.1
- phpstan/extension-installer: ^1.4.3
- spatie/laravel-ray: ^1.39
This package is auto-updated.
Last update: 2025-03-15 15:54:00 UTC
README
This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.
Installation
You can install the package via composer:
composer require coolsam/visual-forms php artisan visual-forms:install
Follow the installation instructions to:
- publish the config file
- publish the migrations
- run the migrations (Optional)
You can run the above steps manually by running the following commands:
To publish the migrations and run them
php artisan vendor:publish --tag="visual-forms-migrations"
php artisan migrate
You can publish the config file with:
php artisan vendor:publish --tag="visual-forms-config"
This is the contents of the published config file:
return [ 'tables' => [ 'visual_forms' => env('VISUAL_FORMS_TABLE', 'visual_forms'), 'visual_form_fields' => env('VISUAL_FORM_FIELDS_TABLE', 'visual_form_fields'), 'visual_form_entries' => env('VISUAL_FORM_ENTRIES_TABLE', 'visual_form_entries'), ], 'models' => [ 'visual_form' => env('VISUAL_FORM_MODEL', \Coolsam\VisualForms\Models\VisualForm::class), 'visual_form_field' => env('VISUAL_FORM_FIELD_MODEL', \Coolsam\VisualForms\Models\VisualFormField::class), 'visual_form_entry' => env('VISUAL_FORM_ENTRY_MODEL', \Coolsam\VisualForms\Models\VisualFormEntry::class), ], ];
Usage
- Register the VisualFormsPlugin in your AdminServiceProvider
use Coolsam\VisualForms\Filament\VisualFormsPlugin; // in your register method $panel->plugin(VisualFormsPlugin::class);
The above command will register the VisualForms resource for managing forms from your backend.
- In any of your forms, use the created form's schema to render it
use Coolsam\VisualForms\Models\VisualForm; // in your form's schema public function form(Form $form) { $recordId = 1; $formModel = VisualForm::find($recordId); return $form->schema($formModel->schema()); }
- To save the form's response payload, execute the following method in your action method:
use Coolsam\VisualForms\Models\VisualForm; // in your form's action method e.g create() public function create(Request $request, VisualForm $record) { $data = $this->form->getState(); $record->recordSubmission($data, isProcessed: false); // TODO: you can send this payload wherever else you want, even to a webhook for further processing }
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.