Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Dynamic Forms

Dynamic Forms Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Add dynamic/dependent fields to Symfony forms

Frequently asked questions about Dynamic Forms
Can I use symfonycasts/dynamic-forms in Laravel without Laravel Collective or Symfony’s Form component?
No, this package requires Symfony’s Form component (v5/6/7). You’ll need to install it manually via Composer (`symfony/form`) or use Laravel Collective (`laravelcollective/html`) for built-in integration. Pure Laravel apps without Symfony dependencies won’t work without additional setup.
How do I handle dynamic fields in Laravel Blade templates with this package?
Render Symfony forms in Blade using `{{ form_row(form) }}` or custom directives. Client-side logic (e.g., showing/hiding fields) requires JavaScript—Alpine.js is recommended for lightweight reactivity. The package doesn’t bundle JS; you’ll need to implement it separately or use a frontend framework like Vue/React.
Will this work with Laravel’s built-in validation (e.g., `$request->validate()`)?
No, it relies on Symfony’s validation system. For hybrid setups, use Symfony’s `Validator` component alongside Laravel’s validation or create middleware to normalize requests. Test edge cases like partial submissions, as Symfony’s validation may behave differently than Laravel’s.
What Laravel versions support symfonycasts/dynamic-forms?
The package works with Laravel 8+ (Symfony 5+) and Laravel 9/10 (Symfony 6/7). Ensure your `symfony/form` version matches Laravel’s Symfony compatibility. For Laravel 11+, check for breaking changes in Symfony 7.x, as this package may lag behind minor updates.
How do I test dynamic forms in Laravel with Pest or PHPUnit?
Test server-side logic (e.g., validation, data binding) with PHPUnit. For client-side behavior (e.g., field visibility toggles), use Pest + Playwright or Laravel Dusk. Mock JavaScript interactions if needed, as dynamic forms depend on frontend logic.
Does this package support multi-step forms or wizards?
Yes, it’s ideal for wizards or progressive disclosure. Use Symfony’s `CollectionType` for repeatable sections or `ChoiceType` with dependent options. Store intermediate state in the session or database, as partial submissions require server-side persistence.
Are there alternatives to symfonycasts/dynamic-forms for Laravel?
For pure Laravel, consider Livewire (for reactive forms) or custom JS with Alpine.js. If you need Symfony integration, `spatie/laravel-forms` or `filament/forms` offer similar dynamic capabilities. This package is unique for its tight Symfony Form component integration.
How do I handle CSRF tokens with Symfony’s CSRFTokenManager in Laravel?
Symfony’s `CSRFTokenManager` may conflict with Laravel’s middleware. Use Laravel’s `@csrf` directive in Blade or create middleware to normalize tokens. Avoid mixing both systems in the same form to prevent validation errors.
Can I lazy-load dynamic form assets (JS/CSS) to improve performance?
Yes, bundle dynamic form assets (e.g., Alpine.js or custom JS) via Vite or Laravel Mix. Use `defer` or dynamic imports for critical paths. For heavy forms, consider server-side rendering (SSR) with Inertia.js or Livewire to reduce client-side load.
What’s the best way to migrate existing Laravel forms to use symfonycasts/dynamic-forms?
Start with low-complexity forms (e.g., user profiles with 2–3 dependent fields). Replace `Form::macro()` or custom Blade helpers with Symfony’s `FormFactory`. Use a service provider to register the factory globally, then incrementally replace forms. Prioritize forms with the highest dynamic needs first.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
bugban/symfony
beyonder-capi/workflow-extensions-bundle
beyonder-capi/job-queue-bundle
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin