Custom Fields v2 introduces a new fluent builder API that simplifies integration while providing more flexibility.
Quick Upgrade
The easiest way to upgrade is using the built-in upgrade command:Manual Upgrade Steps
1. Update Composer
Update yourcomposer.json
to require v2:
2. Database Changes
Custom Fields v2 adds one new column:settings
JSON column incustom_field_options
table
settings
JSON column to the custom_field_options
table.
3. Update Your Code
The main change in v2 is the move from component-based integration to a fluent builder API.Filament Resources - Forms
- v1
- v2
Filament Resources - Tables
- v1
- v2 - Builder API (Recommended)
- v2 - Trait (Still Works)
Filament Resources - Infolists
- v1
- v2
4. Configuration Updates (Required)
Custom Fields v2 introduces improved field type management using fluent configurators. You must update yourconfig/custom-fields.php
to use the new configuration format:
5. Field Type Architecture Changes
Custom Fields v2 now usesBaseFieldType
with FieldSchema
for cleaner field type definitions. If you have custom field types, update them:
- Base Class: Extend
BaseFieldType
(instead of implementing interface directly) - Configuration: Return
FieldSchema
fromconfigure()
method - Benefits: Less boilerplate, better type safety, cleaner API
6. Final Steps
After updating your code, clear all caches:New Features in v2
Fluent Builder API
The new builder API provides more control and flexibility:Breaking Changes
Component-Based Integration Changes
V2 introduces a new builder pattern while maintaining backward compatibility: Forms:CustomFieldsComponent
→ Removed, useCustomFields::form()->forSchema($schema)->build()
- Option 1 (Recommended): Use builder API:
CustomFields::table()->forModel($model)->columns()
and->filters()
- Option 2: Continue using
InteractsWithCustomFields
trait with updated namespace:Relaticle\CustomFields\Concerns\InteractsWithCustomFields
CustomFieldsInfolists
→ Removed, useCustomFields::infolist()->forSchema($schema)->build()
API Changes
- New builder pattern introduced (recommended approach)
InteractsWithCustomFields
trait moved fromRelaticle\CustomFields\Filament\Tables\Concerns\InteractsWithCustomFields
toRelaticle\CustomFields\Concerns
namespace- All builders use
forModel()
method (notforResource()
) - Table builder returns separate
columns()
andfilters()
collections - Infolist can return either
build()
for single component orvalues()
for collection - Field type system completely rewritten
Troubleshooting
Class 'CustomFieldsComponent' not found
Class 'CustomFieldsComponent' not found
Replace with the new builder API:
Trait 'InteractsWithCustomFields' not found
Trait 'InteractsWithCustomFields' not found
The trait has moved to a new namespace:
Custom fields not appearing
Custom fields not appearing
Check these common issues:
- Model must implement
HasCustomFields
and useUsesCustomFields
trait - Use
forModel()
notforResource()
in builders - Clear caches after upgrading
- Verify custom fields exist in database
Table columns or filters missing
Table columns or filters missing
Remember to use spread operator and call the right methods:
Migration Checklist
- Backup your application
- Run
composer require relaticle/custom-fields:"^2.0" -W
- Run
vendor/bin/custom-fields-upgrade
- Update forms:
CustomFieldsComponent::make()
→CustomFields::form()->forSchema($schema)->build()
- Update tables: Either update
InteractsWithCustomFields
namespace OR migrate to...CustomFields::table()->forModel($model)->columns()
- Update infolists:
CustomFieldsInfolists::make()
→CustomFields::infolist()->forModel($model)->build()
- Clear caches and test thoroughly