- How do I replace a standard Nova Select field with a multiselect in my resource?
- Replace `Select::make('Field')` with `Multiselect::make('Field')` in your resource’s `fields()` method. For example, swap `Select::make('Tags')->options($tags)` to `Multiselect::make('Tags')->asyncResource(Tag::class)`. The package mimics Nova’s native field syntax for seamless integration.
- Does this package support Laravel Nova 4.x or 3.x?
- Yes, the package supports Nova 5.x by default, but you can use specific branches for Nova 4.x (`nova-v4`) or 3.x (`nova-v3`). Check the repository’s ‘Other Versions’ section for installation instructions tailored to your Nova version.
- What database column type should I use for multiselect fields?
- Use `string`, `text`, or `varchar` for text-based storage (default). If your database supports JSON (PostgreSQL/MySQL 5.7+), enable `saveAsJSON()` in the field configuration to store values as JSON arrays. This requires no schema changes for existing text columns.
- How do I load options asynchronously for large datasets?
- Use the `asyncResource()` method to dynamically fetch options from an Eloquent model, e.g., `->asyncResource(Artist::class)`. For custom endpoints, pass a URL via `->api('/custom-endpoint')`. Async queries reduce frontend load times but add network latency—test with `optionsLimit()` to balance performance.
- Can I enforce distinct values across multiple multiselect fields?
- Yes, use the `distinct()` method to group fields and prevent duplicate values. For example, `->distinct('category')` ensures no overlapping selections in fields sharing the same group. Note that distinct logic runs client-side, so validate server-side for edge cases like concurrent edits.
- Will this package work with BelongsToMany relationships?
- Yes, the package natively supports `BelongsToMany` relationships. Use `->asyncResource()` with the related model to populate options dynamically. However, avoid unbounded pivot tables—large datasets may degrade UI responsiveness. Test with `optionsLimit()` to optimize performance.
- How do I customize the multiselect UI (e.g., tags, colors, or dark mode)?
- Extend the Vue.js components (e.g., `NovaMultiselectDetailFieldValue`) or override CSS classes. The package supports Nova’s light/dark themes out of the box, but conflicts may require custom styles. Check the `resources/js` directory for entry points to override default behavior.
- Is there a performance impact when using drag-and-drop reordering?
- Drag-and-drop reordering (`->reorderable()`) adds minor frontend overhead but is optimized for small-to-medium lists. For large datasets, consider disabling it or using `optionsLimit()` to reduce the number of rendered options. Test with your expected dataset size to ensure smooth UX.
- Can I add custom tags or values on the fly (like a tagging system)?
- Yes, enable the `taggable()` method to allow users to add new values dynamically. This is useful for open-ended tagging systems. Under the hood, it appends new options to the existing list, but ensure your backend can handle unsaved values if needed.
- What are the risks of using JSON storage for multiselect fields?
- JSON storage (via `saveAsJSON()`) offers better querying capabilities but requires database support (PostgreSQL/MySQL 5.7+). If migrating from text storage, ensure your schema supports JSON columns. Querying individual array elements may need custom database functions or application logic.