Make sure you’ve completed the Installation steps first.
Step 1: Register the Plugin
In yourAdminPanelProvider or panel configuration, register the Custom Fields plugin:
Step 2: Prepare Your Model
Your model needs to implement theHasCustomFields interface and use the UsesCustomFields trait.
In your model (e.g., Product), add the following:
Step 3: Add Custom Fields to Forms
To include custom fields in your resource forms, add theCustomFieldsComponent to your form schema.
In your resource class (e.g., ProductResource), modify the form() method:
Step 4: Display Custom Fields in Tables
To display custom fields in your table views, add theInteractsWithCustomFields trait to your resource’s ListRecords page.
In your list records class (e.g., ListProducts), add the trait:
Step 5: Add Custom Fields to Info Lists
In your resource’sViewRecord page, include the CustomFieldsInfolists component:
Step 6: Include Custom Fields in Exports (Optional)
To include custom fields in your exports, use theCustomFieldsExporter component:
That’s It!
You now have custom fields integrated into your Filament resource! Your users can:- Add custom fields through the admin panel
- Fill out custom fields in forms
- View custom fields in tables and info lists
- Export custom fields data