Closed
Description
Symfony version(s) affected: 5.2.x
This feature was added Symfony 5.2 #35338
Description
Having label_format and translation_domain added in configureOptions doesn't have effect and the label in the message didn't get translated.
How to reproduce
# project.hu.yaml
form.title: cím
# validators.hu.yaml
"This value should not be blank.": "A {{ label }} megadása kötelező!"
// this way it's NOT working
class ProjectType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->add('title', TextType::class ['validators' => new NotBlank()]);
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'label_format' => 'form.%name%',
'translation_domain' => 'project',
]);
}
}
// this way it IS working
class ProjectType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->add('title', TextType::class, [
'label_format' => 'form.%name%',
'translation_domain' => 'project',
'validators' => new NotBlank()
]);
}
}
Expected: "A cím megadása kötelező!"
Got: "A Title megadása kötelező!" + missing translation of 'title' fom 'messages' domain
Possible Solution
Check the form options not just the field options when translating the label for validation messages