Skip to content

[Form] Support "{{ label }}" placeholder in error messages #12238

Closed
@webmozart

Description

@webmozart

Origin of this ticket: #5714

Currently, it is not possible to write error messages that contain the name of the field that they concern. Technically, that's logical, since the Validator component is not aware of the Form component.

However, it would be quite simple to support "{{ label }}" placeholders (or similar). These could be set by the validator to the field's name by default ("title" in the below example), and overwritten in the Form context by the corresponding field's label:

class Article
{
    /**
     * @Assert\NotBlank(message="The field {{ label }} should not be blank.")
     */
    private $title;
}

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