Skip to content

Conversation

@ManukMinasyan
Copy link
Collaborator

@ManukMinasyan ManukMinasyan commented Dec 8, 2025

Summary

This PR introduces several enhancements to the custom fields system:

New Features

  • Multi-value field support - Fields like email can now store multiple values (array format)
  • Unique value validation - New unique_per_entity_type setting ensures values are unique across records
  • Auto-code generation - Field codes can be auto-generated from names (controlled by FIELD_CODE_AUTO_GENERATE feature flag)
  • Sections disabled mode - Flat field list without section grouping (controlled by SYSTEM_SECTIONS_DISABLED feature flag)

Email Field Changes

The email field type has been refactored to use TagsInput for multi-value support:

  • Stores values in json_value column as an array
  • Supports multiple email addresses when allow_multiple is enabled
  • Includes migration command for existing data

Migration Required

If you have existing email field values, run the migration command:

# Preview changes (safe)
php artisan custom-fields:migrate-email-values --dry-run

# Run migration
php artisan custom-fields:migrate-email-values

New Feature Flags

Add to your config/custom-fields.php features array as needed:

CustomFieldsFeature::FIELD_CODE_AUTO_GENERATE,
CustomFieldsFeature::FIELD_MULTI_VALUE,
CustomFieldsFeature::FIELD_UNIQUE_VALUE,
CustomFieldsFeature::SYSTEM_SECTIONS_DISABLED,

Code Quality Improvements

  • Extracted shared Livewire methods into ManagesFields trait (DRY)
  • Extracted field creation logic into CreatesCustomFields trait
  • Removed unused imports and variables
  • Simplified field form layout (entity type now hidden, cleaner grid layout)

Breaking Changes

  • Email field values are now stored as JSON arrays instead of strings
  • Run migration command before deploying to production

Copilot AI review requested due to automatic review settings December 8, 2025 22:12
Copy link

Copilot AI left a 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_type is set twice in the returned array. The spread operator ...$data at line 183 already includes entity_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_type is set twice in the returned array at lines 115-117. The spread operator ...$data at line 115 already includes entity_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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants