From 3954704ddaf0e08acb8ec26d14d4b0e455f0d1f4 Mon Sep 17 00:00:00 2001 From: Luke Towers Date: Mon, 18 Mar 2019 12:39:12 -0600 Subject: [PATCH] Fix issue with multiple repeaters with the same fieldname embedded in the same controller There was a conflict between two repeaters that had the same fieldName (data) bound to the same controller. Example: Controller: Events Manages a ReportTemplate model with a custom popup Form widget that uses a grouped repeater with the field name data to define the available "fields" within a ReportTemplate Also manages Report models through a relation controller that uses a Form widget with a regular repeater with the field name data that defines the values of the fields defined by the associated ReportTemplate. Since both repeaters had the field name of "data", but one of them was grouped and the other wasn't, this would cause an issue in Repeater::processExistingItems() where the grouped repeater would attempt to process the ungrouped repeater's data which would then fail. This issue could easily cause many other vastly more confusing and difficult to detect issues in cases where multiple repeaters with the same field name AND the same mode (grouped vs regular) existed on the same page under different contexts. The simple solution is just to ensure that the indexInputName and groupInputName are both taking the repeater's alias into account when being generated to ensure that everything stays unique like it should. --- modules/backend/formwidgets/Repeater.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/backend/formwidgets/Repeater.php b/modules/backend/formwidgets/Repeater.php index 35088a670..9d3fde0fe 100644 --- a/modules/backend/formwidgets/Repeater.php +++ b/modules/backend/formwidgets/Repeater.php @@ -109,8 +109,8 @@ class Repeater extends FormWidgetBase } $fieldName = $this->formField->getName(false); - $this->indexInputName = self::INDEX_PREFIX.$fieldName; - $this->groupInputName = self::GROUP_PREFIX.$fieldName; + $this->indexInputName = $this->alias.self::INDEX_PREFIX.$fieldName; + $this->groupInputName = $this->alias.self::GROUP_PREFIX.$fieldName; $this->processGroupMode();