Skip to content

Rendering Forms without Translators and Validators #31968

@PF4Public

Description

@PF4Public

Symfony version(s) affected: 4.3.1

Description
When a form is to be rendered, the following code in Twig runs:

{%- if translation_domain is same as(false) -%}               
{{- label -}}            
{%- else -%}
{{- label|trans(label_translation_parameters, translation_domain) -}}

By default translation_domain from validation "is not same as(false) ", which results in calling trans. Which in turn gives an exception

An exception has been thrown during the rendering of a template ("You cannot use the "Symfony\Bridge\Twig\Extension\TranslationExtension" if the Translation Contracts are not available. Try running "composer require symfony/translation".").

Trying to override translation_domain from validation implicitly enables validation and gives another error:

Validation support cannot be enabled as the Validator component is not installed. Try running "composer require symfony/validator".

How to reproduce
Try to render a Form without Translators and Validators

Possible Solution
translation_domain should be false if validation is disabled

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