Skip to content

Commit

Permalink
cache choice field getlistValues() dependent on table name (#1461)
Browse files Browse the repository at this point in the history
  • Loading branch information
tyrant88 authored Jan 16, 2024
1 parent 69ebe76 commit c88c634
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/yform/value/choice.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'] : '',
Expand All @@ -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 = [])
Expand Down

0 comments on commit c88c634

Please sign in to comment.