From c88c634384ad7465629fb555b89db94bc55f53ed Mon Sep 17 00:00:00 2001 From: Norbert Micheel Date: Tue, 16 Jan 2024 12:32:23 +0100 Subject: [PATCH] cache choice field getlistValues() dependent on table name (#1461) --- lib/yform/value/choice.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/yform/value/choice.php b/lib/yform/value/choice.php index 3374d1156..cb23bcd58 100644 --- a/lib/yform/value/choice.php +++ b/lib/yform/value/choice.php @@ -167,9 +167,10 @@ public static function getListValue($params) public static function getListValues($params) { $fieldName = $params['field']; - if (!isset(self::$yform_list_values[$fieldName])) { - $field = $params['params']['field']; + $field = $params['params']['field']; + $tableName = $field['table_name']; + if (!isset(self::$yform_list_values[$tableName][$fieldName])) { $choiceList = self::createChoiceList([ 'choice_attributes' => (isset($field['choice_attributes'])) ? $field['choice_attributes'] : '', 'choice_label' => (isset($field['choice_label'])) ? $field['choice_label'] : '', @@ -183,10 +184,10 @@ public static function getListValues($params) $choices = $choiceList->getChoicesByValues(); foreach ($choices as $value => $label) { - self::$yform_list_values[$fieldName][$value] = $label; + self::$yform_list_values[$tableName][$fieldName][$value] = $label; } } - return self::$yform_list_values[$fieldName] ?? ''; + return self::$yform_list_values[$tableName][$fieldName] ?? ''; } public function getAttributes($element, array $attributes = [], array $directAttributes = [])