Closed gremo closed 3 years ago
We could maybe set the translation_domain
in https://github.com/sonata-project/SonataAdminBundle/blob/db09b03adee7ae24379d0462af329467b4a83e29/src/Form/Extension/Field/Type/FormTypeFieldExtension.php#L95
And there check if the translation_domain
option is false and there is admin
, set it to the admin translation domain and there is no need to override the blocks in twig.
PS: Thanks for reporting it!
Can you please try to add:
if (false === $options['translation_domain']) {
$view->vars['translation_domain'] = $sonataAdmin['admin']->getTranslationDomain();
}
Just to check, if that's ok I'll try to make a PR, if we could avoid overriding these blocks will be great.
EDIT: for the future me or if someone is willing to do it, instead of overriding translation_domain
in FormTypeFieldExtension.php
, we could use a new sonata_admin_translation_domain
view var and in twig override translation_domain
when is needed.
@franmomu translation_domain
seems null
not false
when not passing it.
That is, your code is not working (line 157 of SonataAdminBundle/src/Form/Extension/Field/Type/FormTypeFieldExtension.php
)
if (false === $options['translation_domain']) {
$view->vars['translation_domain'] = $sonataAdmin['admin']->getTranslationDomain();
}
On the contrary, this is working (but don't know the side effects):
if (!isset($options['translation_domain'])) {
$view->vars['translation_domain'] = $sonataAdmin['admin']->getTranslationDomain();
}
@franmomu
translation_domain
seemsnull
notfalse
when not passing it.That is, your code is not working (line 157 of
SonataAdminBundle/src/Form/Extension/Field/Type/FormTypeFieldExtension.php
)if (false === $options['translation_domain']) { $view->vars['translation_domain'] = $sonataAdmin['admin']->getTranslationDomain(); }
On the contrary, this is working (but don't know the side effects):
if (!isset($options['translation_domain'])) { $view->vars['translation_domain'] = $sonataAdmin['admin']->getTranslationDomain(); }
Oops, yes, I thought null
and I wrote false
, false
is when the user explicitly says don't want label and null
if not specified.
I added some tests in https://github.com/sonata-project/SonataAdminBundle/pull/7020, after that I'll create a sonata_admin_translation_domain
and only use it in form_help
and if that's fine I think we could remove some code of form_label
in 4.x
to be safe.
Thank you! You mean this will not be fixed in 3.x (that's the version I use)?
Thank you! You mean this will not be fixed in 3.x (that's the version I use)?
No, no. I'll make the PR for 3.x
.
The comment about 4.x
was that I think we can remove some code using this new sonata_admin_translation_domain
(in form_label
) and I'd rather do it in 4.x
to be safe.
Using version 3.79
Bug introduced with this commit (I suppose): https://github.com/sonata-project/SonataAdminBundle/commit/77326c4427895be3a724a876a61ea660990344a5#diff-35d3133a895a9ec1948258059dc0265ac33c1959eca60d39b3a61726dbeb6f66, somewhere after 3.65 (I can see "old" admin not showing this problem).
The block looks like this:
Which calls the symfony block:
... where
translation_domain
is null, fallback to "messages" (while all my admin have "admin" as translation domain).The right thing to do is the same as for form_label, that is using the admin domain.
Now I'm forced to do:
or even worst:
For each field of every admin I have.