From a35fd76053b9a8f8d2a0d9de1fa2d945370dd4da Mon Sep 17 00:00:00 2001 From: nobohan Date: Wed, 4 Apr 2018 22:01:52 +0200 Subject: [PATCH] fix deprecations: add choices_as_values=true + flip contents of choice in ChoiceType --- CustomFields/CustomFieldChoice.php | 3 ++- Form/Type/ChoiceWithOtherType.php | 1 + Form/Type/LinkedCustomFieldsType.php | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CustomFields/CustomFieldChoice.php b/CustomFields/CustomFieldChoice.php index 6738b32c8..81e57df87 100644 --- a/CustomFields/CustomFieldChoice.php +++ b/CustomFields/CustomFieldChoice.php @@ -85,7 +85,8 @@ class CustomFieldChoice extends AbstractCustomField //prepare $options $options = array( 'multiple' => $customFieldOptions[self::MULTIPLE], - 'choices' => $choices, + 'choices' => array_combine(array_values($choices),array_keys($choices)), + 'choices_as_values' => true, 'required' => $customField->isRequired(), 'label' => $this->translatableStringHelper->localize($customField->getName())); diff --git a/Form/Type/ChoiceWithOtherType.php b/Form/Type/ChoiceWithOtherType.php index 8f4b4b02c..beab31337 100644 --- a/Form/Type/ChoiceWithOtherType.php +++ b/Form/Type/ChoiceWithOtherType.php @@ -34,6 +34,7 @@ class ChoiceWithOtherType extends AbstractType $options['expanded'] = true; // adding a default value for choice $options['empty_data'] = null; + $options['choices_as_values'] = true; $builder ->add('_other', TextType::class, array('required' => false)) diff --git a/Form/Type/LinkedCustomFieldsType.php b/Form/Type/LinkedCustomFieldsType.php index 90b89bc1b..d14bb67ce 100644 --- a/Form/Type/LinkedCustomFieldsType.php +++ b/Form/Type/LinkedCustomFieldsType.php @@ -110,6 +110,7 @@ class LinkedCustomFieldsType extends AbstractType $options = array_merge($this->options, array( 'choice_list' => new SimpleChoiceList($choices), + 'choices_as_values' => true )); $event->getForm()->getParent()->add($this->choiceName, ChoiceType::class,