- How do I install the laravel-nova-field-dynamic-select package?
- Install it with Composer using composer require kayacekovic/laravel-nova-field-dynamic-select. Because it is a Nova field, it belongs in the require block of your application rather than a package you publish assets for. After installing, import the field class in your Nova resource and add it to the fields method just like the built-in Select field. Check the README for the exact namespace and any required setup steps for your Nova version.
- Which Laravel Nova versions does this dynamic select field support?
- The package is built for Laravel Nova and follows Nova's field conventions, so it targets modern Nova releases. Nova 4 and 5 changed field internals compared with Nova 3, so confirm the supported constraint in the package's composer.json or README before upgrading. If you are on an older Nova version, test in a staging resource first. Pinning a compatible package version in composer.json is the safest approach.
- How do I create a dependent dropdown in a Laravel Nova resource?
- Add the Dynamic Select field to your resource's fields method and point it at the field or fields whose values should drive its options. When those parent fields change in the form, the select refreshes its option list without a page reload. This lets you build country to region, category to subcategory, or any other cascading choice. The README shows the exact method names for declaring the dependency and the option source.
- Do I need to write custom JavaScript or Vue components to use it?
- No. The point of the package is to handle the reactive behaviour inside a ready-made Nova field, so you avoid writing and maintaining your own Vue component. You configure dependencies and options in PHP inside your Nova resource. That keeps the form logic in one place and makes it easier to review in code. For unusual cases you can still fall back to a custom field, but most dependent dropdowns should not need one.
- Can the select options be loaded from the database or an Eloquent model?
- Yes. Options are supplied from PHP, so you can build them from an Eloquent query, a config array, an enum, or any other server-side source. A common pattern is to filter a model query using the value of the parent field. Because the options are resolved per request, keep queries lean and indexed so the form stays responsive. Refer to the README for how options are passed to the field.
- Does it work with BelongsTo and relationship fields in Nova?
- The field behaves like a standard select, so it stores a single value that a relationship field can resolve, such as a foreign key. Whether it can replace a BelongsTo field directly depends on how you configure the option values and the underlying column. For relationship-heavy forms, many developers keep the relationship field and use a dynamic select for secondary dependent data. Verify the expected value format in the README before wiring it to a relationship.
- How do I test a Nova resource that uses a dynamic select field?
- Nova resource tests typically instantiate the resource and assert on the fields returned by the fields method, then exercise the store and update endpoints. You can assert the field is present and that its options resolve correctly for a given parent value. Keep option-resolution logic in your application code where it can be unit tested without booting Nova. That makes the field itself a thin presentation layer.
- Does the field work in Nova's index, detail, and inline creation contexts?
- Dynamic selects are primarily a form-field feature, since they depend on the current values of other fields in the same form. On the index and detail views there is no live form state, so the field renders the resolved stored value. Inline creation modals and nested forms should be checked individually for your Nova version. If a context matters to your workflow, test it before rolling the package out.
- How is this different from Nova's built-in Select field?
- Nova's built-in Select field has a fixed option list declared when the field is created. This package adds reactivity so the option list changes in response to other form values, which normally requires a custom Vue component. If your dropdowns never depend on other inputs, the built-in field is simpler and needs no extra dependency. Choose this package when you specifically need dependent or conditional choices.
- Is this package maintained and safe to use in production?
- It is a small, focused field package from an individual maintainer, so review the repository's commit history, open issues, and release tags before adopting it. Check the composer.json constraints to confirm it matches your Nova and Laravel versions. Because it only extends Nova's field layer, it is usually easy to swap out if you later replace it. Pin the version you have tested and review changelogs on upgrade.