Skip to content

[Form] Misused HTML5 attributes #39066

@Chi-teck

Description

@Chi-teck

Symfony version(s) affected: 5.1.8

Description
The pattern attribute is only allowed on the following input types.

  • text
  • tel
  • email
  • url
  • password
  • search

How to reproduce
Define Lenth contstraint on some entity property

/**
 * @ORM\Column(type="text")
 * @Assert\NotBlank()
 * @Assert\Length(min="150")
 */
private string $description;

Check out markup of rendered entity form. It'll look something like this.

<textarea id="company_description" name="company[description]" required="required" pattern=".{150,}" aria-describedby="company_description_help" class="form-control"></textarea>

Additional context
For textareas it looks like a regression because it was fixed long tiime ago (#2676) and even got a test (38f64a1).

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