Nested schema in filament v4
Good day everyone,
I’m new to Filament and I’d like to ask if it’s possible (or allowed) to use a nested schema function inside another schema.
Here’s my current setup. I created a tasks schema that returns a table:
And I also have a cardSchema:
What I’d like to do is reuse the tasks schema inside the cardSchema, something like this:
My question is: Is this the right way to include the tasks schema inside the cardSchema?
If not, could you please suggest the correct approach or best practice for this kind of setup?
I’m still learning Filament and trying to figure out the right patterns. Any advice would be appreciated.
2 Replies
I'm still on v3, so maybe wrong, but from glancing at your question, I would elevate the schema array into its own class and then call it from whereever I wanted.
Yes, it is allowed! But, you have to extract the schema itself (the
array
of schema) into a static method. Then call it anywhere else, like this TaskForm::getSchemaArray()
and that should return you an array.
Now, if you want to merge existing schema and the task
schema, you need to do ...TaskForm::getSchemaArray()
and it should work