- How do I install x-form in a Laravel 13 project?
- Run `composer require vkm-apps/x-form` and publish the config with `php artisan vendor:publish --tag=x-form-config`. Ensure Livewire 3 is installed (`composer require livewire/livewire`). The package integrates seamlessly with Laravel’s Blade templating.
- Does x-form support Laravel 9 or older versions?
- x-form officially supports Laravel 9+, but v2.0.0 explicitly targets Laravel 13. For older versions, use v1.x with Livewire 2. Check the [release notes](https://github.com/vkm-apps/x-form/releases) for version-specific requirements.
- Can I use x-form without Livewire?
- No, x-form requires Livewire for server-driven reactivity. AlpineJS is used for client-side interactivity but isn’t a replacement for Livewire’s core functionality. If you need a non-Livewire solution, consider alternatives like Laravel Collective or custom Blade components.
- How do I handle dynamic fields (e.g., nested arrays) with x-form?
- Use the `<x-form.editor>` component for dynamic arrays. It supports nested validation and rendering via Livewire’s array syntax. For complex cases, leverage AlpineJS’s `x-model` or Livewire’s `$rules` for custom validation logic.
- Is there a risk of XSS when rendering form errors?
- Yes, the package uses `{{!! $message !!}}` for error rendering, which bypasses Blade escaping. Mitigate this by wrapping errors in `{{ e($message) }}` or `{{ htmlspecialchars($message) }}` in your Blade templates.
- How do I customize the styling of x-form components?
- Override default styles via the `x-form-config:css` configuration or by publishing the package’s assets. Use AlpineJS hooks or custom CSS classes to modify individual components (e.g., `.x-form-input`).
- Can I test x-form components in isolation?
- Yes, test components like `<x-form.input>` or `<x-form.date-range>` using Laravel’s Blade testing helpers or Livewire’s `render()` method. Focus on validation, error handling, and AlpineJS interactions in your tests.
- What’s the performance impact of using x-form for large forms?
- Livewire’s hydration model can introduce latency for forms with many components. Mitigate this by using partial hydration (e.g., `wire:ignore` for static fields) or lazy-loading sections. Benchmark with 10+ components to assess TTFB.
- How do I migrate from Livewire 2 to Livewire 3 with x-form?
- Upgrade Livewire first (`composer require livewire/livewire:^3.0`), then update x-form to v2.x. Review the [Livewire migration guide](https://laravel-livewire.com/docs/3.x/upgrading) for breaking changes, especially in validation or component syntax.
- Are there alternatives to x-form for Laravel form handling?
- Yes, consider Laravel Collective’s `laravelcollective/html` for basic forms, or InertiaJS for SPA-like workflows. For Livewire-specific alternatives, explore `filament/forms` (Filament UI) or `spatie/laravel-form-builder`. Choose based on your need for reactivity vs. simplicity.