From 2f7b46fbacd90e553e0f73df546cceed5b4efac5 Mon Sep 17 00:00:00 2001 From: Philipp Dieter Date: Mon, 2 Aug 2021 11:30:22 +0200 Subject: [PATCH] [TASK] Add additional function to create select tca --- Classes/Utility/TcaUtility.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/Classes/Utility/TcaUtility.php b/Classes/Utility/TcaUtility.php index c188135..76fc289 100644 --- a/Classes/Utility/TcaUtility.php +++ b/Classes/Utility/TcaUtility.php @@ -42,6 +42,34 @@ class TcaUtility $tca['columns'][$column]['config']['items'] = $options; } + /** + * fills object from array + * + * @return void + */ + public static function configureSelectFromArray( + &$tca, $column, $element, $options, $extensionKey = null + ) { + $items = []; + foreach ($options as $option) { + $translationKey = "option.$element.$column.$option"; + $translation = self::getTranslation( + $translationKey, + $extensionKey + ); + if ($translation) { + $items[] = [$translation, $option]; + } else { + $items[] = [$translationKey, $option]; + } + } + $tca['columns'][$column]['config']['type'] = 'select'; + $tca['columns'][$column]['config']['renderType'] = 'selectSingle'; + $tca['columns'][$column]['config']['size'] = 6; + $tca['columns'][$column]['config']['appearance'] = []; + $tca['columns'][$column]['config']['items'] = $items; + } + /** * shortcut to get translation *