Skip to content

Single-mode Date fieldtype crashes on save when format includes time (Carbon::parse array given) #14860

Description

@damjanuzelac

Bug description

When a date fieldtype is in single mode and its effective save format includes a time component, saving an entry throws a TypeError. The Control Panel submits the value as a ['date' => ..., 'time' => ...] array, but Date::processSingle()processDateTime() passes it straight to Carbon::parse(), which doesn't accept arrays.

This affects the default date field, because a single-mode field with no explicit format falls back to defaultFormat() = Y-m-d H:i, so formatHasTime() returns true. Note time_enabled does not influence formatHasTime() — only the format string does.

Range mode works because processRange() reads $data['start'] / $data['end'] individually; single mode never combines {date, time}. Still present on master.

How to reproduce

Minimal, no CP needed — php artisan tinker:

$ft = (new Statamic\Fields\Field('event_date', ['type' => 'date']))->fieldtype();
$ft->formatHasTime(); // true (default saveFormat is 'Y-m-d H:i')
$ft->process(['date' => '2026-06-29', 'time' => '22:00']);
// TypeError: Carbon\Carbon::parse(): Argument #1 ($time) must be of type
// ...|null, array given, called in .../Fieldtypes/Date.php on line 254

Or via CP: add a date field (single mode, empty format) to a collection blueprint → create/save an entry → TypeError.

Expected behavior

Entry saves; {date, time} is combined into a single datetime string before parsing.

Actual behavior

TypeError: Carbon\Carbon::parse(): Argument #1 ($time) must be of type DateTimeInterface|...|null, array given at Date.php:254.

Workaround

Set an explicit date-only format: 'Y-m-d' on the field so formatHasTime() is false.

Environment

  • Statamic: v6.22.0
  • Laravel: 12.62 · PHP: 8.5.7
  • Platform-independent

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions