symfonycasts/dynamic-forms
Build dynamic, AJAX-friendly Symfony forms where fields appear, disappear, or change based on user input. Provides an event-driven approach to updating form options and validation, making complex dependent form flows easier to implement and maintain.
laravel-forms or filament/forms). If the app already uses Symfony-based form handling, adoption is seamless.Form::open(), Blade directives) lacks built-in dynamic field support, creating a clear opportunity for this package to fill that gap.Form component (v5/6/7). Laravel apps must either:
laravelcollective/html).form component (higher maintenance).Form component is opinionated; version conflicts (e.g., Laravel 10 + Symfony 6.4) may arise. Risk mitigated by using symfony/forms as a standalone dependency.symfony/form as a standalone composer dependency.FormView rendering.Form::macro() or livewire/forms (overlap exists).FormFactory globally.@dynamicForm) to wrap Symfony forms.// app/Providers/AppServiceProvider.php
use Symfony\Component\Form\FormFactoryInterface;
$this->app->singleton(FormFactoryInterface::class, fn($app) => \Symfony\Component\Form\FormFactoryBuilder::create()->getFormFactory());
EntityType, ChoiceType, CollectionType, etc.).Validator component to unify validation logic.@symfonycasts/dynamic-forms entry).CSRFTokenManager may conflict with Laravel’s. Use middleware to normalize tokens.symfony/form, symfony/validator, and JS dependencies.FormBuilder.data-dynamic-form attributes).composer.json.debugbar to inspect Symfony form data.FormBuilder API (e.g., add(), getConfig()).alpine:debounce.300ms).FormInterface for DTOs and validate at the API boundary.| Failure Type | Symptoms | Mitigation |
|---|---|---|
| JS Dependency Breakage | Dynamic fields not updating. | Fallback to server-side rendering. |
| Symfony Version Conflict | Form submission fails with ClassNotFound. |
Use platform_check in composer.json. |
| CSRF Token Mismatch | "Invalid CSRF token" errors. | Normalize tokens via middleware. |
| Validation Mismatch | Client-side JS validation ≠ server. | Use Symfony’s Validator for unified rules. |
| Asset Loading Issues | JS/CSS not loading. | Verify Vite/Webpack includes the package. |
FormBuilder basics (e.g., SymfonyCasts videos).FormDebugger or Laravel’s dd($form->createView()).Sentry for JS errors).How can I help you explore Laravel packages today?