-
Notifications
You must be signed in to change notification settings - Fork 19
Feature/enhancements #57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 2.x
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds several significant enhancements to the custom fields system including multi-value field support, unique value constraints, auto-generated codes, and a sections-disabled mode. The changes introduce new features for greater flexibility while maintaining backward compatibility.
Key changes:
- Multi-value field support (e.g., multiple emails per field) with configurable max values
- Unique value validation per entity type with a new validation rule
- Auto-generation of field and section codes from names when enabled
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Support/CodeGenerator.php | New utility for generating unique codes from names with collision handling |
| src/Services/DefaultSectionService.php | Service to manage default hidden sections when sections feature is disabled |
| src/Rules/UniqueCustomFieldValue.php | Custom validation rule for enforcing unique field values per entity type |
| src/Services/ValidationService.php | Enhanced to support type-specific rules and entity ID for unique checks |
| src/Models/CustomField.php | Added getTypeSettings() method for retrieving typed field-specific settings |
| src/Livewire/ManageFieldsWithoutSections.php | New component for managing fields in flat mode without visible sections |
| src/Livewire/ManageCustomFieldSection.php | Integrated code auto-generation for new fields |
| src/Filament/Management/Pages/CustomFieldsManagementPage.php | Added sections-disabled mode support with default section creation |
| src/Filament/Management/Schemas/SectionForm.php | Made code field optional when auto-generation is enabled |
| src/Filament/Management/Schemas/FieldForm.php | Added UI for multi-value, unique value, and type-specific settings |
| src/Filament/Integration/Components/Forms/EmailComponent.php | Changed to TagsInput for multi-email support with validation |
| src/Filament/Integration/Base/AbstractFormComponent.php | Updated validation rules to pass entity ID for unique checks |
| src/FieldTypeSystem/FieldSchema.php | Added supportsMultiValue configuration |
| src/FieldTypeSystem/Definitions/EmailFieldType.php | Reconfigured as multi-choice field type with multi-value support |
| src/Data/FieldTypeData.php | Added supportsMultiValue property |
| src/Data/CustomFieldSettingsData.php | Added allow_multiple, max_values, and unique_per_entity_type settings |
| src/Enums/CustomFieldsFeature.php | Added feature flags for new capabilities |
| src/CustomFieldsServiceProvider.php | Registered new ManageFieldsWithoutSections Livewire component |
| resources/views/livewire/manage-fields-without-sections.blade.php | View template for flat field management without sections |
| resources/views/livewire/manage-custom-field-width.blade.php | Dark mode styling improvements |
| resources/views/livewire/manage-custom-field-section.blade.php | Styling adjustments for empty state |
| resources/views/filament/pages/custom-fields-management.blade.php | Conditional rendering for sections-disabled mode |
| resources/lang/en/custom-fields.php | Added translations for new features and empty states |
Comments suppressed due to low confidence (2)
src/Livewire/ManageCustomFieldSection.php:186
- [nitpick] Same issue as in ManageFieldsWithoutSections:
entity_typeis set twice in the returned array. The spread operator...$dataat line 183 already includesentity_type(from line 167's fillForm), and then it's explicitly set again at line 184. Consider removing the duplicate assignment.
src/Livewire/ManageFieldsWithoutSections.php:117 - [nitpick] The
entity_typeis set twice in the returned array at lines 115-117. The spread operator...$dataat line 115 already includesentity_type(from line 100's fillForm), and then it's explicitly set again at line 116. While this doesn't cause an error (the second assignment overwrites the first), it's redundant. Consider removing the duplicate assignment at line 116 since it's already in$data.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
This PR introduces several enhancements to the custom fields system:
New Features
unique_per_entity_typesetting ensures values are unique across recordsFIELD_CODE_AUTO_GENERATEfeature flag)SYSTEM_SECTIONS_DISABLEDfeature flag)Email Field Changes
The email field type has been refactored to use
TagsInputfor multi-value support:json_valuecolumn as an arrayallow_multipleis enabledMigration Required
If you have existing email field values, run the migration command:
New Feature Flags
Add to your
config/custom-fields.phpfeatures array as needed:Code Quality Improvements
ManagesFieldstrait (DRY)CreatesCustomFieldstraitBreaking Changes