You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The bug:
While having a liveform with required select and placeholder of type TranslatableMessage, instead of leaving this value blank, first not null value from choices is retrieved instead.
This behaviour occurs because of code in Symfony\UX\LiveComponent\ComponentWithFormTrait in if on line 276.
In this if, the last condition is !\is_string($child->vars['placeholder']) which unfortunately is not satisfied e.g. for option 'placeholder' => new TranslatableMessage('some.value').
Solution
I would suggest to extending this condition to (!\is_string($child->vars['placeholder']) && !$child->vars['placeholder'] instanceof TranslatableMessage) or making it only !isset($child->vars['placeholder']) to support more cases. I feel that string only restriction is to harsh when most of the time, we will be creating multilingual applications.
We use TranslatableMessage class for translatable strings so our extractor can generate .yaml files with translations.
The text was updated successfully, but these errors were encountered:
I would suggest to extending this condition to (!\is_string($child->vars['placeholder']) && !$child->vars['placeholder'] instanceof TranslatableMessage)
Would you like to open a PR ?
or making it only !isset($child->vars['placeholder']) to support more cases
The bug:
While having a liveform with required select and placeholder of type TranslatableMessage, instead of leaving this value blank, first not null value from choices is retrieved instead.
This behaviour occurs because of code in
Symfony\UX\LiveComponent\ComponentWithFormTrait
in if on line 276.ux/src/LiveComponent/src/ComponentWithFormTrait.php
Line 276 in 314ca71
In this if, the last condition is
!\is_string($child->vars['placeholder'])
which unfortunately is not satisfied e.g. for option'placeholder' => new TranslatableMessage('some.value')
.Solution
I would suggest to extending this condition to
(!\is_string($child->vars['placeholder']) && !$child->vars['placeholder'] instanceof TranslatableMessage)
or making it only!isset($child->vars['placeholder'])
to support more cases. I feel that string only restriction is to harsh when most of the time, we will be creating multilingual applications.We use TranslatableMessage class for translatable strings so our extractor can generate .yaml files with translations.
The text was updated successfully, but these errors were encountered: