Load create form fields from backend depending on select
Pretty basic stuff, yet I can't really find the right approach compatible with Laravel Nova.
I'd basically like to have two types of Transfers, one inner and one outer. When creating a transfer, I'd like to select the type (only on frontend, such column does not exist), then based on the selected value (either inner or outer), populate the creation form with further fields, defined somewhere...
For example:
- if the transfer is inner, it should have
toWarehousefield (actually a relation on a pivot betweenTransferandItem), where it should list filtered warehouses belonging to the same company; - if the transfer is outer, it should have
toCompanyfield (actually a direct belongsTo relation on the transfer)
Now, since some of those fields would require non-standard hydration (like the toWarehouse for example, but also further ones), I guess that the standard creation page won't be an option. So I was wondering, is there a swift way to achieve that behaviour? Maybe a custom standalone action, a resource tool or a completely new tool? And how would I go about replacing the default "Create Transfer" button with my custom action/tool? For starters, pointing me in the most appropriate direction would be enough! Any advice is greatly appreciated!
Please or to participate in this conversation.