Skip to content

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

@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

      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