This section will guide you through setting up and using the Custom Fields plugin in your Filament admin panel.
Publish the migration files:
Run the migrations:
If you wish to customize the configuration, publish the config file:
This will create a custom-fields.php
file in your config
directory.
To use Custom Fields, you need to register the plugin with your Filament panel.
Your model needs to implement the HasCustomFields
interface and use the UsesCustomFields
trait to work with custom
fields.
In your model (e.g., Company
), add the following:
By following these steps, your model will be fully equipped to handle custom fields, and you will have successfully set up Custom Fields in your Filament application, enabling dynamic and flexible data management.
To include custom fields in your resource forms, you’ll use the CustomFieldsComponent
. This component dynamically adds
all the custom fields associated with the resource.
In your resource class (e.g., CompanyResource
), modify the form()
method:
To display custom fields in your table views, you need to use the InteractsWithCustomFields
trait in your
resource’s ListRecords
page.
In your list records class (e.g., ListCompanies
), add the trait:
This trait automatically includes all custom fields in the table view for the resource.
In your resource’s ViewRecord
page or wherever you define the info list schema, include the CustomFieldsInfolists
component:
To include custom fields in your exports, you can leverage the CustomFieldsExporter
component, which is designed to integrate seamlessly with Filament’s exporting tools. Below is your CompanyExporter
class, which shows how to implement this:
This section will guide you through setting up and using the Custom Fields plugin in your Filament admin panel.
Publish the migration files:
Run the migrations:
If you wish to customize the configuration, publish the config file:
This will create a custom-fields.php
file in your config
directory.
To use Custom Fields, you need to register the plugin with your Filament panel.
Your model needs to implement the HasCustomFields
interface and use the UsesCustomFields
trait to work with custom
fields.
In your model (e.g., Company
), add the following:
By following these steps, your model will be fully equipped to handle custom fields, and you will have successfully set up Custom Fields in your Filament application, enabling dynamic and flexible data management.
To include custom fields in your resource forms, you’ll use the CustomFieldsComponent
. This component dynamically adds
all the custom fields associated with the resource.
In your resource class (e.g., CompanyResource
), modify the form()
method:
To display custom fields in your table views, you need to use the InteractsWithCustomFields
trait in your
resource’s ListRecords
page.
In your list records class (e.g., ListCompanies
), add the trait:
This trait automatically includes all custom fields in the table view for the resource.
In your resource’s ViewRecord
page or wherever you define the info list schema, include the CustomFieldsInfolists
component:
To include custom fields in your exports, you can leverage the CustomFieldsExporter
component, which is designed to integrate seamlessly with Filament’s exporting tools. Below is your CompanyExporter
class, which shows how to implement this: