Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IBX-6636: ezSelection default label 'ALL' is incorrect for NOT multiple choice setting #76

Open
wants to merge 1 commit into
base: 4.6
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading