diff --git a/src/Resources/contao/classes/DataContainer.php b/src/Resources/contao/classes/DataContainer.php index 0528969347..cf4c7f6d91 100644 --- a/src/Resources/contao/classes/DataContainer.php +++ b/src/Resources/contao/classes/DataContainer.php @@ -1113,6 +1113,27 @@ protected function getPickerInputField($value, $attributes='') return ''; } + /** + * Return the data-picker-value attribute with the currently selected picker values (see #1816) + * + * @return string + */ + protected function getPickerValueAttribute() + { + // Only load the previously selected values for the checkbox field type (see #2346) + if ($this->strPickerFieldType != 'checkbox') + { + return ''; + } + + $values = array_map($this->objPickerCallback, $this->arrPickerValue); + $values = array_map('strval', $values); + $values = json_encode($values); + $values = htmlspecialchars($values); + + return ' data-picker-value="' . $values . '"'; + } + /** * Build the sort panel and return it as string * diff --git a/src/Resources/contao/drivers/DC_Folder.php b/src/Resources/contao/drivers/DC_Folder.php index f7432fb54a..80b33e3fb7 100644 --- a/src/Resources/contao/drivers/DC_Folder.php +++ b/src/Resources/contao/drivers/DC_Folder.php @@ -444,14 +444,6 @@ public function showAll() $icon = $GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['icon'] ?: 'filemounts.svg'; $label = Image::getHtml($icon) . ' '; - // Pass previously selected values to picker (#1816) - $prevPickerValue = ''; - - if ($this->strPickerFieldType) - { - $prevPickerValue = ' data-picker-value="' . htmlspecialchars(json_encode(array_map('strval', $this->arrPickerValue))) . '"'; - } - // Build the tree $return = $this->panel() . Message::generate() . '