- Can I use this bundle directly in Laravel without Symfony dependencies?
- No, this bundle is designed for Symfony and requires `symfony/form` as a dependency. For Laravel, you’d need to either add Symfony’s Form component or create a custom wrapper (e.g., using Form macros or a Blade directive) to replicate fieldset functionality natively.
- How do I install this in a Laravel project?
- Install via Composer with `composer require adamquaile/symfony-fieldset-bundle`, but note this is Symfony-focused. For Laravel, you’d need to register the bundle in a Symfony-compatible environment (e.g., API Platform) or build a Laravel-specific adapter. A native Laravel solution would avoid Symfony dependencies entirely.
- Does this bundle support Laravel’s Blade templating engine?
- No, this bundle is built for Symfony’s Twig. In Laravel, you’d need to manually wrap fields in `<fieldset>` tags using Blade directives or JavaScript, or create a custom Form macro to generate the HTML. The bundle’s Twig templates won’t render in Blade by default.
- Will this work with Laravel 10.x or Symfony 6.x?
- Unlikely—this bundle’s last release was in 2017 for Symfony 2.x/3.x. You’d need to fork it and update dependencies (e.g., `symfony/form`) to support newer versions, or consider alternatives like Livewire panels or custom Blade components for field grouping.
- Can I define fieldsets in Laravel using an array like the Symfony example?
- Not directly, but you could replicate the array-based approach in Laravel by creating a Form macro or helper function. For example, a macro like `Form::fieldset()` could accept an array of fields and wrap them in `<fieldset>` tags with a legend, mimicking the bundle’s array configuration.
- Does this bundle handle Laravel’s validation (e.g., FormRequest) or Symfony’s constraints?
- This bundle uses Symfony’s validation system (e.g., constraints). In Laravel, validation would need to be handled separately via FormRequest rules or custom validation logic. The fieldset itself doesn’t enforce validation groups—you’d need to manually bind validation rules to the grouped fields.
- Are there Laravel-native alternatives to this bundle?
- Yes. For field grouping, consider Laravel’s Form macros, Livewire components (e.g., panels), or packages like `laravel-formcomponents/core`. These avoid Symfony dependencies and integrate seamlessly with Blade. Custom Blade directives or JavaScript (e.g., Alpine.js) can also group fields without extra packages.
- How do I integrate this bundle with Laravel’s session/CSRF protection?
- This bundle doesn’t interact with Laravel’s session or CSRF systems directly. If using it in a Laravel app via Symfony’s Form component, ensure your form includes Laravel’s `@csrf` directive and session handling. For native Laravel forms, CSRF and session management work as usual without conflicts.
- Can I use this bundle in a Laravel Livewire component?
- Indirectly, but it’s not recommended. Livewire components already support field grouping via HTML or custom Blade logic. Adding this Symfony bundle would introduce unnecessary complexity. Instead, use Livewire’s built-in features or create a custom fieldset component in Blade.
- What’s the performance impact of using this bundle in Laravel?
- Minimal if used in a Symfony-compatible Laravel environment (e.g., API Platform). However, adding Symfony dependencies (like `symfony/form`) could increase bundle size and autoloading time. For native Laravel implementations (e.g., Form macros), the impact is negligible since it’s just HTML wrapping logic.