Skip to content

Navigation Menu

Sign in
Appearance settings

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 field type not guessed for DateTime with doctrine/annotations 1.10 #37423

Copy link
Copy link
Closed
@rmdefi

Description

@rmdefi
Issue body actions

Symfony version(s) affected: 4.4.10 (but probably also symfony 5)

Description

The ValidatorTypeGuesser (from the form component) can use the Type constraint to guess the field type if no better contraints are available. To guess a DateType component, it compares the type to the string '\DateTime' (with a leading backslash).
In doctrine/annotation 1.10, when the class is specified with as ::class, the leading backslash is now removed, so the DateType is not guessed anymore.
see doctrine/annotations#142

How to reproduce

Create a simple data class with a field annotated only with the Type constraint:

class Data {
	/**
	 * @Assert\Type(\DateTime::class)
	 */
	public $myDate;
}

Then try to guess the type of the field myDate with doctrine/annotation 1.10 or 1.8.
If testing in a full symfony framework, clear the cache after changing doctrine/annotation, to have the class parsed again.

Possible Solution

Add a test for the string 'DateTime' (without the leading backslash)

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

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