Skip to content

feat: add configurable date display formats [3.x]#129

Merged
ManukMinasyan merged 3 commits into3.xfrom
fix/configurable-date-display-format
Mar 30, 2026
Merged

feat: add configurable date display formats [3.x]#129
ManukMinasyan merged 3 commits into3.xfrom
fix/configurable-date-display-format

Conversation

@ManukMinasyan
Copy link
Copy Markdown
Collaborator

@ManukMinasyan ManukMinasyan commented Mar 30, 2026

Summary

  • Add configurable date display formats via CustomFieldsPlugin (Filament-idiomatic) and CustomFields facade
  • All Filament components (forms, tables, infolists) and validation messages respect the configured format
  • When no format is configured (default), each component uses its original hardcoded format (full BC)

Usage

Via Plugin (recommended)

CustomFieldsPlugin::make()
    ->authorize(fn () => auth()->user()->isAdmin())
    ->dateDisplayFormat('m/d/Y')
    ->dateTimeDisplayFormat('m/d/Y h:i A')

Via Facade

// In AppServiceProvider::boot()
CustomFields::useDateDisplayFormat('m/d/Y');
CustomFields::useDateTimeDisplayFormat('m/d/Y h:i A');

Components Updated

Component Default (unchanged) Reads from
CustomFieldsPlugin -- Sets facade values in boot()
DateComponent (form) Y-m-d dateDisplayFormat()
DateTimeComponent (form) Y-m-d H:i:s dateTimeDisplayFormat()
DateTimeColumn (table) M j, Y / M j, Y H:i Both
DateTimeEntry (infolist) Y-m-d / Y-m-d H:i:s Both
DateConstraintRule (validation) M j, Y dateDisplayFormat()

Not changed (intentionally)

  • AbstractFormComponent::getFieldValue() -- storage format for hydration (Y-m-d), not display
  • ImportColumnConfigurator -- storage format for parsing imports
  • DateConstraintField -- management UI date picker storage format

Test plan

  • Verify default behavior unchanged when no format configured
  • Verify plugin configuration applies to all components
  • Verify facade configuration applies to all components
  • Verify validation messages use configured format
  • PHPStan passes
  • Pint passes
  • 459/466 tests pass (7 pre-existing failures unrelated to this change)

Copilot AI review requested due to automatic review settings March 30, 2026 15:35
Copy link
Copy Markdown

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

Adds global configuration hooks to control how date and datetime custom fields are displayed across the package’s Filament integrations, while aiming to preserve each component’s existing defaults when unset.

Changes:

  • Introduces CustomFields::useDateDisplayFormat() / useDateTimeDisplayFormat() plus getters to store global display format configuration.
  • Updates Filament form date/datetime pickers to use configured display formats.
  • Updates Filament table column + infolist entry rendering to format date/datetime values using the configured formats.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/CustomFields.php Adds static configuration storage + API for date/datetime display formats.
src/Filament/Integration/Components/Forms/DateComponent.php Reads configured date display format for DatePicker display/placeholder.
src/Filament/Integration/Components/Forms/DateTimeComponent.php Reads configured datetime display format for DateTimePicker display/placeholder.
src/Filament/Integration/Components/Tables/Columns/DateTimeColumn.php Formats date/datetime table values using configured formats.
src/Filament/Integration/Components/Infolists/DateTimeEntry.php Formats infolist date/datetime display using configured formats.

@ManukMinasyan ManukMinasyan force-pushed the fix/configurable-date-display-format branch from fcddc7d to a585e2e Compare March 30, 2026 16:13
Allow applications to set global date/datetime display formats via
CustomFieldsPlugin or CustomFields facade. All Filament components
(forms, tables, infolists) and validation messages respect the
configured format while preserving BC with null defaults.
@ManukMinasyan ManukMinasyan force-pushed the fix/configurable-date-display-format branch from a585e2e to b335b11 Compare March 30, 2026 16:23
- Use sample date as placeholder instead of raw PHP format string
- Use ->date() for date-only fields in DateTimeEntry infolist
- Accept nullable format in facade setters to allow resetting to defaults
@ManukMinasyan ManukMinasyan merged commit c0816b6 into 3.x Mar 30, 2026
2 checks passed
@ManukMinasyan ManukMinasyan deleted the fix/configurable-date-display-format branch March 30, 2026 16:50
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