Skip to content

Commit 0984bef

Browse files
stehledKocal
authored andcommitted
Fix issue 2621
1 parent 9d42463 commit 0984bef

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/LiveComponent/composer.json

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"symfony/property-access": "^5.4.5|^6.0|^7.0",
3232
"symfony/property-info": "^5.4|^6.0|^7.0",
3333
"symfony/stimulus-bundle": "^2.9",
34+
"symfony/translation-contracts": "^2.5|^3.0",
3435
"symfony/ux-twig-component": "^2.8",
3536
"twig/twig": "^3.8.0"
3637
},

src/LiveComponent/src/ComponentWithFormTrait.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\Form\FormInterface;
1717
use Symfony\Component\Form\FormView;
1818
use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
19+
use Symfony\Contracts\Translation\TranslatableInterface;
1920
use Symfony\UX\LiveComponent\Attribute\LiveProp;
2021
use Symfony\UX\LiveComponent\Attribute\PreReRender;
2122
use Symfony\UX\LiveComponent\Util\LiveFormUtility;
@@ -286,7 +287,10 @@ private function extractFormValues(FormView $formView): array
286287
)
287288
&& !$child->vars['expanded'] // is a <select> (not a radio/checkbox)
288289
&& !$child->vars['multiple'] // is not multiple
289-
&& !\is_string($child->vars['placeholder']) // has no placeholder (empty string is valid)
290+
&& (
291+
!\is_string($child->vars['placeholder'])
292+
&& !$child->vars['placeholder'] instanceof TranslatableInterface
293+
) // has no placeholder (empty string is valid, translatable interface is valid)
290294
) {
291295
$choices = $child->vars['preferred_choices'] ?: $child->vars['choices']; // preferred_choices has precedence, as they rendered before regular choices
292296
do {

0 commit comments

Comments
 (0)