F
Filament17mo ago
Lars

Dynamically load Form input into schema.

I am trying to dynamically load the schema for a tab. I will explain the behaviour I except: - On the edit/create page for a product I can select a category that that product is in. - A category has characteristics with a type (Number or Text for now maybe more in the future). - After selecting the category the characteristic fields should be displayed to characteristic tabs Does anybody know if something like this is possible? Thanks! Notes; product has a belongsToMany relation with characteristic. The pivot table for product and characteristic has a third column for the value of that combination.
Solution:
It sounds like characteristics are your fields, so load all the category characteristics fields in then set their visibility depending on the category? Or render the fields based on the selected value with the category select being reactive and the tabs schema building inside a schema function returning an array...
Jump to solution
3 Replies
slamx_
slamx_17mo ago
Hey lars, you can use ->hidden(fn (Closure $get) => for the characteristic fields. It allows you to hide the field by a specific field value. For example: >hidden(fn (Closure $get) => !$get['select_cat'])
Lars
LarsOP17mo ago
Yes I know that but this would require me defining all fields for all characteristic. But I want to be able to add characteristic via the characteristicresource and than dynamically add a input field for that characteristic.
Solution
toeknee
toeknee17mo ago
It sounds like characteristics are your fields, so load all the category characteristics fields in then set their visibility depending on the category? Or render the fields based on the selected value with the category select being reactive and the tabs schema building inside a schema function returning an array
Want results from more Discord servers?
Add your server