Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Form] Use error_mapping in DateTimeType #58135

Copy link
Copy link
Open
@SVillette

Description

@SVillette
Issue body actions

Description

Given a form type with a date time field using two simple text widget, it is currently not possible to use the error_mapping option on the date and time children.

After some investigation, I found that the DateTimeType defines the error_bubling to true for the date and the time fields. In the example below, when a violation is created, is is mapped to startsAt.date but is bubbled up to startsAt.

https://github.com/symfony/symfony/blob/7.2/src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php#L166

I could work on a PR as I don't see any easy fix. An option like date_error_bubling/time_error_bubling would do the trick ?
Or should I add date_options/time_options that would override the options passed to these fields ?

Example

$builder
    ->add('startsAt', DateTimeType::class, [
        'date_widget' => 'single_text',
        'time_widget' => 'single_text',
        'error_mapping' => [
            '.' => 'date',
        ],
    ]);

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.