From 6633473a2ba2d9363fb7ed5a6fd19d2816e02a9b Mon Sep 17 00:00:00 2001 From: Kamil Kuzminski Date: Tue, 21 Dec 2021 15:59:54 +0100 Subject: [PATCH] Fix the problem with an empty dropdown menu when adding a new MCW row for repeat exceptions field --- src/Resources/contao/dca/tl_calendar_events.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/Resources/contao/dca/tl_calendar_events.php b/src/Resources/contao/dca/tl_calendar_events.php index d313fe1..3b1a436 100644 --- a/src/Resources/contao/dca/tl_calendar_events.php +++ b/src/Resources/contao/dca/tl_calendar_events.php @@ -1172,6 +1172,7 @@ public function setmaxperson($dc) public function listMultiExceptions($var1) { $columnFields = null; + $activeRecord = $var1->activeRecord; // arrays for the select fields $arrSource1 = array(); @@ -1180,8 +1181,17 @@ public function listMultiExceptions($var1) $arrSource4 = array(); if (\Input::get('id')) { - if ($var1->activeRecord->repeatDates) { - $arrDates = deserialize($var1->activeRecord->repeatDates); + // Probably an AJAX request where activeRecord is not available + if ($activeRecord === null) { + $activeRecord = \Database::getInstance() + ->prepare("SELECT * FROM {$var1->strTable} WHERE id=?") + ->limit(1) + ->execute(\Input::get('id')) + ; + } + + if ($activeRecord->repeatDates) { + $arrDates = deserialize($activeRecord->repeatDates); if (is_array($arrDates)) { if ($var1->id == "repeatExceptions") { // fill array for option date @@ -1281,7 +1291,7 @@ public function listMultiExceptions($var1) } // exceptions by interval elseif ($var1->id == "repeatExceptionsInt") { $firstField = array( - 'label' => $GLOBALS['TL_LANG']['tl_calendar_events']['exceptionInt'] . $GLOBALS['TL_LANG']['DAYS'][$var1->activeRecord->weekday], + 'label' => $GLOBALS['TL_LANG']['tl_calendar_events']['exceptionInt'] . $GLOBALS['TL_LANG']['DAYS'][$activeRecord->weekday], 'exclude' => true, 'inputType' => 'select', 'options' => array('first', 'second', 'third', 'fourth', 'fifth', 'last'),