Skip to content

Commit

Permalink
IBX-6636: ezSelection default label 'ALL' is incorrect for NOT multip…
Browse files Browse the repository at this point in the history
…le choice setting
  • Loading branch information
vidarl committed Nov 13, 2024
1 parent 19ee7c7 commit cb5702c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@
<target state="new">Content location</target>
<note>key: content_forms.relation.location_type.self</note>
</trans-unit>
<trans-unit id="3753c5a7d2bddee50d6ffe5148884aa1ff5bfcb8" resname="content.field_type.ezselection.none">
<source>None</source>
<target state="new">None</target>
<note>key: content.field_type.ezselection.none</note>
</trans-unit>
</body>
</file>
</xliff>
17 changes: 17 additions & 0 deletions src/lib/FieldType/Mapper/SelectionFormMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,19 @@
use Ibexa\ContentForms\Form\Type\FieldType\SelectionFieldType;
use Ibexa\Contracts\ContentForms\Data\Content\FieldData;
use Ibexa\Contracts\ContentForms\FieldType\FieldValueFormMapperInterface;
use JMS\TranslationBundle\Annotation\Desc;
use Symfony\Component\Form\FormInterface;
use Symfony\Contracts\Translation\TranslatorInterface;

class SelectionFormMapper implements FieldValueFormMapperInterface
{
private TranslatorInterface $translator;

public function __construct(TranslatorInterface $translator)
{
$this->translator = $translator;
}

public function mapFieldValueForm(FormInterface $fieldForm, FieldData $data)
{
$fieldDefinition = $data->fieldDefinition;
Expand All @@ -29,6 +38,13 @@ public function mapFieldValueForm(FormInterface $fieldForm, FieldData $data)
$choices = $fieldDefinition->fieldSettings['multilingualOptions'][$fieldDefinition->mainLanguageCode];
}

$placeholder = $this->translator->trans(
/** @Desc("None") */
'content.field_type.ezselection.none',
[],
'ibexa_content_forms_fieldtype',
);

$fieldForm
->add(
$formConfig->getFormFactory()->createBuilder()
Expand All @@ -40,6 +56,7 @@ public function mapFieldValueForm(FormInterface $fieldForm, FieldData $data)
'label' => $fieldDefinition->getName(),
'multiple' => $fieldDefinition->fieldSettings['isMultiple'],
'choices' => array_flip($choices),
'placeholder' => $placeholder,
]
)
->setAutoInitialize(false)
Expand Down

0 comments on commit cb5702c

Please sign in to comment.