diff --git a/ExternalModule.php b/ExternalModule.php index 5e6f95c..32356e7 100644 --- a/ExternalModule.php +++ b/ExternalModule.php @@ -183,10 +183,11 @@ function setDefaultValues() { // Getting previous event value. // isset returns true for event instances when $prev_event_field_value is equal to an empty string (""). // An additional check to verify the value is not empty is required. + $source_form = ($_GET['instance'] > 1) ? $source_form : ""; $prev_event_field_value = $data[$prev_event][$source_field]; if (isset($prev_event_field_value) && !empty($prev_event_field_value)) { $default_value = $prev_event_field_value; - } elseif ($data['repeat_instances'][$prev_event][$source_form]) { + } elseif (isset($data['repeat_instances'][$prev_event][$source_form])) { // Handling repeat events by using the most recent instance of the previous event to source values $most_recent_instance = array_slice($data['repeat_instances'][$prev_event][$source_form], -1)[0]; $default_value = $most_recent_instance[$source_field];