- Can I use antona/form-collection-bundle in Laravel 10+ for dynamic form collections like product bundles or multi-step surveys?
- Yes, but with some setup. The bundle is Symfony-based, so you’ll need to wrap its `OnlinqCollectionType` in a Laravel-compatible FormBuilder class. Laravel’s FormRequest validation will work alongside Onlinq’s client-side UX. Start by extending Laravel’s `FormBuilder` facade or creating a custom wrapper for the Symfony form logic.
- How do I integrate Onlinq’s JavaScript web components with Laravel Mix or Vite for asset bundling?
- Add Onlinq’s script and CSS to your `resources/js/app.js` or `vite.config.js` via CDN or npm. For Laravel Mix, use `mix.scripts()` or `mix.copy()`. For Vite, import the script directly. Ensure the components load after Laravel’s CSRF token and Alpine.js/Vue if used. Test with `npm run dev` or `npm run build` to confirm no conflicts.
- Will this bundle work with Laravel’s FormRequest validation or do I need to duplicate rules in Symfony’s FormType?
- Laravel’s FormRequest validation remains the primary source of truth. Onlinq handles client-side UX like drag-and-drop and real-time validation, but backend rules in `FormRequest` will still apply. You may need to map Symfony’s `FormInterface` errors to Laravel’s `errors()->has()` for Blade rendering consistency.
- Are there Laravel-specific Blade templates for the Bootstrap 5 themes, or do I have to manually convert Twig templates?
- The bundle provides Twig themes, but you’ll need to manually convert them to Blade (e.g., replace `{% extends %}` with `@extends`). The structure is similar enough that Bootstrap 5 components like buttons, modals, and form groups will translate directly. Check the README for theme structure hints.
- What’s the best way to handle nested collections (e.g., User[0][Address][0]) in Laravel’s Request object when using this bundle?
- Onlinq’s web components will generate nested input names automatically, but Laravel’s `Request` object may need help parsing them. Use `Request::all()` or `Request::input('User.0.Address.0')` to access nested data. For validation, define rules in `FormRequest` like `'User.*.Address.*.city' => 'required'`.
- Does this bundle support Laravel’s Livewire or Inertia.js for SPA-like form handling?
- Not natively, but you can integrate Onlinq’s web components alongside Livewire/Inertia. Load Onlinq’s JS in your Livewire component’s `@stack('scripts')` or Inertia page’s `<script>` section. Ensure CSRF tokens and Alpine.js (if used) don’t conflict. Test drag-and-drop functionality in both client-side and server-rendered modes.
- How do I handle validation errors when using Onlinq’s client-side components with Laravel’s error bag?
- Onlinq’s components will show client-side errors (e.g., real-time feedback), but Laravel’s `errors()->has()` will still populate Blade templates. Use `@error('field')` in your Blade views to display server-side errors. For dynamic collections, loop through `errors()->all()` and match them to Onlinq’s input IDs or classes.
- What’s the performance impact of using Onlinq’s web components in a Laravel app with many dynamic forms?
- Onlinq’s components add ~50–100KB to your payload (JS + CSS). For large forms, lazy-load components with Alpine.js or load them dynamically via `fetch()` or `axios`. Test with Lighthouse or WebPageTest to monitor render-blocking delays. Consider bundling only the components you need.
- Are there alternatives to this bundle for Laravel that offer similar drag-and-drop form collections?
- Yes. For Laravel-native solutions, try **spatie/laravel-form-builder** (simpler) or **livewire/form-builder** (if using Livewire). For Vue.js, **vee-validate** with **vue-dnd-list** offers drag-and-drop. If you need Symfony-like features, **laravel-symfony-form** bridges Symfony’s FormComponent to Laravel, but lacks Onlinq’s web components.
- How do I test this bundle in Laravel’s PHPUnit, especially for form submission and validation?
- Mock the Symfony `FormInterface` in your tests by creating a wrapper class that implements Laravel’s `FormRequest` expectations. Use `FormRequest::fake()` to simulate submissions. Test Blade rendering with `Blade::render()` and assert Onlinq’s HTML structure. For JS interactions, use Pest or Laravel Dusk to verify drag-and-drop and client-side validation.