Share the same $form and $table between Resource, RelationshipManager, createOptionForm
Hi,
I'm new to filamentphp, and mostly a Front-end developer.
I've had to add some things in an existing project, and haven't had too much problems, but I feel like I keep repeating the same forms and fields over and over...
Is there a way to define the fields once, and reuse them between the Resource, RelationshipManager and createOptionForm ?
And what is the best practices around that ?
8 Replies
Exemple:


The problem is that if I add a field, I need to remember to add it to all 3 places !
@Exi Thank you, since this is the v4 docs, was this not documented at all in v3, or is it somewhere else in the doc ?
@Exi How would that with
Nvm I found out how:
createOptionForm
since I can't pass $schema
to configure
?->createOptionForm(fn(Form $form) => AuthorResource::form($form))
@Exi So I would create a Schemas folder inside my Resources like so ?
Is there a reason why my resource is not inside that same folder ?
I'm on v3, and use the CLI like so the create the model and resources:

Neither v3 nor v4 enforces a folder structure. The v4 docs just give an example. Use any layout you like; putting the resource in Schemas is okay, I think.
The CLI generated drastically different output
You can stick to that layout if you prefer