Skip to content

Date/time form input doesn't allow changing seconds #59942

@nunoplopes

Description

@nunoplopes

Symfony version(s) affected

symfony/form 5.4.45

Description

The following code creates an HTML widget that has the seconds fixed to the value in $time. Attempting to submit the form with different seconds makes the browser reject the request.
This is because the time is formatted with seconds and current behaviors don't handle that well.

Documentation mentions a with_seconds option, disabled by default, which I thought it would change the format to exclude seconds, but it doesn't.
This makes date/time forms a bit unsuable.

How to reproduce

$form->add('date', DateTimeType::class, [
  'data'     => $time,
  'input'    => 'datetime_immutable',
  'widget'   => 'single_text',
]);

Possible Solution

When with_seconds option is disabled, formatting of time should not include seconds.

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions