© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
24 replies
flex

How to handle records of different "type" and different fields depending on the type?

Hey! I have a simple model called "Visual". It has the fields
name
name
(string),
type
type
(enum) and
settings
settings
(json). In a CMS the record should represent any type of visual objects like an image, a slider, a video, a chart, a pdf, whatever.. Each type has completely different fields which should be stored into
settings
settings
column. So for example image just have a FileUpload. A slider has multiple FileUploads, a chart may have just a Codefield to insert a iframe-code or whatever...
How can I use different fields depending on the selected type in the Select for "type"?

To may make it little bit more challenging (for me): For each of those visual types we have packages to only install only the types we need for the website. The packages register them self in a VisualTypeRegistry. A VisualType object has a
getKey() ``getLabel() 
getKey() ``getLabel() 
and
getSchema()
getSchema()
function. Building the type Select works well depending on the key and the label. But now I don't know how to tell filament to use the getSchema() for the selected type.
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Show different records depending on user roles
FilamentFFilament / ❓┊help
2y ago
Depending fields
FilamentFFilament / ❓┊help
11mo ago
How to handle hidden fields of a model?
FilamentFFilament / ❓┊help
3y ago
How to lock table records from being selected, depending on other selected Records
FilamentFFilament / ❓┊help
13mo ago