Skip to content

[Form] Do not fail reverse transforming relative dates #28703

@trompette

Description

@trompette

Description

Since v2.8.46, relative dates are not supported anymore by DateTimeType.

I am guessing this is because of the patches :

It would be great to introduce the feature again by adding a dedicated value of the format option, or anything better you can think of.

Example

At @lrqdo, the relative dates are helping us simplify our Behat scenarios.

Here is an example of a Behat scenario failing on v2.8.46:

When I send a POST request to "/endpoint" with values:
  | distributionDate | +14 days |
Then the response code should be 200
  Failed asserting that 400 is identical to 200.

Here is the form type we wrote:

public function buildForm(FormBuilderInterface $builder, array $options)
{
    $builder->add(
        'distributionDate',
        DateTimeType::class,
        array(
            'widget' => 'single_text',
        )
    );
}

And here is the detailed error we get:

image

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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy