diff --git a/EMS/core-bundle/src/Form/DataField/ChoiceFieldType.php b/EMS/core-bundle/src/Form/DataField/ChoiceFieldType.php index b48d21c82..bcb2a6c44 100644 --- a/EMS/core-bundle/src/Form/DataField/ChoiceFieldType.php +++ b/EMS/core-bundle/src/Form/DataField/ChoiceFieldType.php @@ -17,7 +17,7 @@ class ChoiceFieldType extends DataFieldType { private ?int $fakeIndex = null; - /** @var array */ + /** @var array */ private array $choices; public function getLabel(): string @@ -221,8 +221,8 @@ public function viewTransform(DataField $dataField) } /** - * @param array $options - * @return array + * @param array $options + * @return array */ private function buildChoices(array $options): array { @@ -240,11 +240,11 @@ private function buildChoices(array $options): array } } - if ($options['linked_collection']) { + if (\is_string($options['linked_collection'] ?? null)) { $idx = 0; - if (isset($options['raw_data'][$options['linked_collection']]) && \is_array($options['raw_data'][$options['linked_collection']])) { + if (\is_array($options['raw_data'][$options['linked_collection']] ?? null)) { foreach ($options['raw_data'][$options['linked_collection']] as $idx => $child) { - $choices['#'.$idx.': '.((isset($child[$options['collection_label_field']]) && null !== $child[$options['collection_label_field']]) ? $child[$options['collection_label_field']] : '')] = $idx; + $choices['#'.$idx.': '.((null !== ($child[$options['collection_label_field'] ?? 'label'] ?? null)) ? $child[$options['collection_label_field']] : '')] = $idx; } ++$idx; }